#Lutece0284. The lastest Math theory problem

The lastest Math theory problem

Migrated from Lutece 284 The lastest Math theory problem

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

There is a positive integer NN,satisfied that Na1\frac{N} { a_1} equals K1a1K_1^{a_1}, Na2\frac{N} { a_2} equals K2a2K_2^{a_2} and so on. Then, I want you to tell me the smallest NN.

Input

Input is a integer n(1n6)n(1 \leq n \leq 6), then n numbers ai(16<ai1000)a_i (16 < a_i \leq 1000 )described above.

Output

If there exists such a NN,output NN mod 1988050219880502, else -1 instead.

Samples

1
323
2
17 19
323
3493625

Note

The data used in this problem is unofficial data prepared by VioletWall. So any mistake here does not imply mistake in the offcial judge data.

Resources

HDOJ Monthly Contest – 2010.06.05