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

#GL0000114. Nhân một tập con (Subset Multiplication)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Nhân một tập con (Subset Multiplication)

Subset Multiplication

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Alice starts with an array aa of positive integers where ai−1a_{i-1} divides aia_i for all 2≤i≤n2\le i\le n. Bob chooses a positive integer xx and multiplies an arbitrary subset of positions (possibly empty or all positions) by xx to obtain the given array bb. Find any xx in [1,109][1,10^9] for which a suitable original array and subset exist. A solution is guaranteed.

Input

The first line contains nn. The second line contains b1,…,bnb_1,\dots,b_n.

Output

Print a valid positive integer xx.

Subtasks

  • Subtask 1 (20 points): 2≤n≤302\le n\le30, 1≤bi≤1031\le b_i\le10^3.
  • Subtask 2 (30 points): 2≤n≤30002\le n\le3000, 1≤bi≤1061\le b_i\le10^6.
  • Subtask 3 (50 points): 2≤n≤6⋅1052\le n\le6\cdot10^5, 1≤bi≤1091\le b_i\le10^9.

Examples

Input

4
4 8 4 8

Output

4

Explanation

Starting from (1,2,4,8)(1,2,4,8) and multiplying the first two entries by x=4x=4 produces (4,8,4,8)(4,8,4,8).