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

#GL0000116. ƯCLN trên bảng (GCD on Blackboard)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

ƯCLN trên bảng (GCD on Blackboard)

GCD on Blackboard

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn positive integers a1,a2,…,ana_1,a_2,\ldots,a_n on a blackboard. Choose exactly one position and replace its value with any integer from 11 to 10910^9, possibly the same value. Find the largest possible GCD of all nn integers after the replacement.

Input

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

Output

Print the maximum attainable GCD.

Subtasks

  • Subtask 1 (20 points): 2≤n≤502\le n\le 50; 1≤ai≤1 0001\le a_i\le 1\,000.
  • Subtask 2 (30 points): 2≤n≤5 0002\le n\le 5\,000; 1≤ai≤1 000 0001\le a_i\le 1\,000\,000.
  • Subtask 3 (50 points): 2≤n≤100 0002\le n\le 100\,000; 1≤ai≤1 000 000 0001\le a_i\le 1\,000\,000\,000.

Examples

Input

3
7 6 8

Output

2

Explanation

Replace 7 with 4 to obtain 4, 6, 8, whose GCD is 2. No larger GCD is possible.