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

#GL0000042. UCLN lớn nhất trong một dãy số (Maximum GCD)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

UCLN lớn nhất trong một dãy số (Maximum GCD)

Maximum GCD

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Given NN positive integers, consider every pair of distinct indices i<ji<j. Find the maximum value of gcd⁡(ai,aj)\gcd(a_i,a_j). Equal values at different positions still form a valid pair.

Input

The first line contains NN; the following line contains exactly NN positive integers.

Output

Print the maximum GCD over all pairs.

Subtasks

  • Subtask 1 (20 points): 2≤N≤82 \le N \le 8; 1≤ai≤1001 \le a_i \le 100
  • Subtask 2 (30 points): 2≤N≤602 \le N \le 60; 1≤ai≤10001 \le a_i \le 1000
  • Subtask 3 (50 points): 2≤N≤1002 \le N \le 100; 1≤ai≤1061 \le a_i \le 10^{6}

Examples

Input

4
12 15 18 24

Output

12

Explanation

The pair 12,2412,24 has GCD 1212, which is not exceeded by any other pair.