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

#GL0000095. Orac và BCNN (Orac and LCM)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Orac và BCNN (Orac and LCM)

Orac and LCM

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given a sequence of n≥2n\ge2 positive integers a1,a2,…,ana_1,a_2,\ldots,a_n, compute lcm⁡(ai,aj)\operatorname{lcm}(a_i,a_j) for every pair of indices 1≤i<j≤n1\le i<j\le n. Collect these values into a multiset TT (including duplicates). Find the GCD of all values in TT.

Input

The first line contains nn. The second line contains nn positive integers a1,a2,…,ana_1,a_2,\ldots,a_n.

Output

Print the GCD of the LCMs of all index pairs.

Subtasks

  • Subtask 1 (20 points): 2≤n≤302\le n\le30; 1≤ai≤1001\le a_i\le100.
  • Subtask 2 (30 points): 2≤n≤20002\le n\le2000; 1≤ai≤1041\le a_i\le10^4.
  • Subtask 3 (50 points): 2≤n≤1052\le n\le10^5; 1≤ai≤2⋅1051\le a_i\le2\cdot10^5.

Examples

Input

4
10 24 40 80

Output

40

Explanation

The six pairwise LCMs are 120,40,80,120,240,80120,40,80,120,240,80. Their GCD is 4040, so the answer is 4040.