#K5096. Maximum GCD After Removing One Element

    ID: 28980 Type: Default 1000ms 256MiB

Maximum GCD After Removing One Element

Maximum GCD After Removing One Element

Jaime loves playing with sequences of numbers and often challenges his friends with puzzles. In this problem, you are given a sequence of n integers \(a_1, a_2, \ldots, a_n\). Your task is to compute the maximum value of the greatest common divisor (GCD) obtainable after removing exactly one element from the sequence. Note that if only one element remains, its GCD is the element itself.

Formally, for each \(i\) with \(1 \le i \le n\), remove the element \(a_i\) and compute the GCD of the remaining \(n-1\) elements. Output the maximum GCD obtained over all possible removals.

Input Format: The first line of input contains a single integer n. The second line contains n space-separated integers \(a_1, a_2, \ldots, a_n\).

Output Format: Print a single integer which is the maximum GCD obtainable by removing exactly one element from the array.

Constraints: It is guaranteed that \(n \ge 2\) and all \(a_i\) are positive integers.

inputFormat

The input is given via standard input (stdin) and consists of two lines. The first line contains an integer n (\(n \ge 2\)), denoting the number of elements in the sequence. The second line contains n space-separated integers \(a_1, a_2, \ldots, a_n\).

outputFormat

Output a single integer on standard output (stdout) which represents the maximum GCD achievable by removing one element from the sequence.

## sample
3
3 9 15
3

</p>