This page is still under construction.

Parts of this page are still being built. What you see may change.

LCM of Primes

Interview

Time limit1sMemory limit512 MB

Summary
Given a sequence of N numbers, take the prime values among them and print their least common multiple, or -1 if none are prime.
Level

Medium4 of 10

Topics
Number theory, Math, Implementation, Brute force
Solved
No attempts yet

Problem

Happi wants to pick out the primes in a sequence AA of length NN and find their least common multiple.

Help Happi compute this value.

Input

The first line gives the length NN of the sequence AA. (1≤N≤10,000)(1 \le N \le 10,000)

The next line gives the elements AiA_i of AA, separated by spaces. (2≤Ai≤1,000,000)(2 \le A_i \le 1,000,000)

Only inputs whose answer is less than 2632^{63} are given.

Output

Print the least common multiple of the primes on the first line.

If there are no primes, print -1.

Examples2

  1. Example 1

    Input
    5
    2 3 5 6 8
    
    Expected output
    30
    
  2. Example 2

    Input
    4
    4 16 64 256
    
    Expected output
    -1