GCD Choice
Practice
3.3 (9 votes)
Basic math
Algorithms
Math
Problem
94% Success 1690 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

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.

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
463 votes
Tags:
Ad-HocEasy-MediumMathamatics
Points:30
39 votes
Tags:
MathematicsOpenApprovedEasy-MediumMathamatics
Points:30
6 votes
Tags:
MathematicsEasy-MediumMathematicsMathamatics