GCD Choice

3.3

9 votes
, Basic Math, Algorithms, Math
Problem

Y has no one to talk but he has an array a1,a2,...,an. Y wants to remove one element of array, so the gcd value of the remaining array (gcd(a1,a2,...,aj1,aj+1,...,an)j is removed) is maximum.

What is the maximum value Y can get by removing exactly one element of the array?

Input

First line contains only n, legnth of array.

Second line contains the array elements a1,a2,...,anseparated by space.

2n2×105

1ai109

Output

The only line of output contains an integer, maximum value value that Y can get.

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

If Y removes the last element, gcd value of the remaining array will become gcd(6,2,6,6,2)=2.

Editor Image

?