PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000164. Gần như tất cả các ước (Almost All Divisors)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Gần như tất cả các ước (Almost All Divisors)

Almost All Divisors

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

A hidden positive integer xx has all its positive divisors listed. Exactly 11 and xx are removed, and you receive the complete remaining list, in arbitrary order with distinct entries. Find the smallest possible integer xx whose divisors other than 11 and xx are exactly the given values. Print -1 if no such integer exists.

Input

The first line contains nn, the number of provided divisors. The second line contains nn pairwise distinct integers d1,…,dnd_1,\ldots,d_n.

Output

Print the minimum possible xx, or -1 when the list is inconsistent.

Subtasks

  • Subtask 1 (20 points): 1≤n≤101 \le n \le 10; 2≤di≤1032 \le d_i \le 10^3.
  • Subtask 2 (30 points): 1≤n≤801 \le n \le 80; 2≤di≤1052 \le d_i \le 10^5.
  • Subtask 3 (50 points): 1≤n≤3001 \le n \le 300; 2≤di≤1062 \le d_i \le 10^6.

Examples

Input

8
8 2 12 6 4 24 16 3

Output

48

Explanation

The positive divisors of 4848 are 1,2,3,4,6,8,12,16,24,481,2,3,4,6,8,12,16,24,48. Removing 11 and 4848 leaves exactly the eight provided numbers.