Replicants' IDs P73645


Statement
 

pdf   zip

html

[r]

Los Angeles. Dr. Eldon Tyrell from Tyrell Corporation has decided to identify each replicant with a number. He has chosen a set of prime numbers, and has given instructions to the workers at the factory to use as ID for a new replicant the smallest available number that can be obtained by multiplying the numbers of the set.

Given the set of prime numbers, can you compute the ID of the m-th replicant produced?

Input

Input consists of several cases. Every case begins with an integer number m ≥ 1, followed by a number n, followed by n different prime numbers. Assume 1 ≤ n ≤ 104.

Output

For every case, print the ID of the m-th replicant. This number will be smaller than 231.

Public test cases
  • Input

    1   1  2
    2   1  2
    3   1  2
    5   4  2 5 7 3
    11  4  2 5 7 3
    19  4  2 5 7 3
    

    Output

    2
    4
    8
    6
    14
    27
    
  • Information
    Author
    Albert Graells
    Language
    English
    Official solutions
    C++
    User solutions
    C++