Y has no one to talk but he has an array \(a_1, a_2, ..., a_n\). Y wants to remove one element of array, so the gcd value of the remaining array (\(gcd(a_1, a_2, ..., a_{j-1}, a_{j+1}, ..., a_n)\), \(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 \(a_1, a_2, ..., a_n\)separated by space.
\(2 \leq n \leq 2 \times 10^5\)
\(1 \leq a_i \leq 10^9\)
Output
The only line of output contains an integer, maximum value value that Y can get.
If Y removes the last element, gcd value of the remaining array will become \(gcd(6, 2, 6, 6, 2) = 2\).
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor