Replicants' IDs P73645


Statement
 

pdf   zip

ifnextchar ( ifnextchar (offsettrue(0pt,0pt) offsetfalse ifnextchar [(0pt,0pt)(0pt,0pt) ifnextchar [(0pt,0pt)(0pt,0pt)[l](0pt,0pt)(0pt,0pt)[l][] [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 mm-th replicant produced?

Input

Input consists of several cases. Every case begins with an integer number m1m \ge 1, followed by a number nn, followed by nn different prime numbers. Assume 1n1041 \le n \le 10^4.

Output

For every case, print the ID of the mm-th replicant. This number will be smaller than 2312^{31}.

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++