Problem:
Score : 300 points

Problem Statement

There are N integers, A_1, A_2, ..., A_N, written on the blackboard.

You will choose one of them and replace it with an integer of your choice between 1 and 10^9 (inclusive), possibly the same as the integer originally written.

Find the maximum possible greatest common divisor of the N integers on the blackboard after your move.

Constraints

All values in input are integers.

2 \leq N \leq 10^5

1 \leq A_i \leq 10^9

Output

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the maximum possible greatest common divisor of the N integers on the blackboard after your move.

Sample Input 1

3
7 6 8

Sample Output 1

2

If we replace 7 with 4, the greatest common divisor of the three integers on the blackboard will be 2, which is the maximum possible value.

Sample Input 2

3
12 15 18

Sample Output 2

6

Sample Input 3

2
1000000000 1000000000

Sample Output 3

1000000000

We can replace an integer with itself.

Solution in Rust (1.15.1) (judge verdict: Runtime Error)

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
trait ProperDivisors {
    fn proper_divisors(&self) -> Option<Vec<i64>>;
}
 
impl ProperDivisors for i64 {
    fn proper_divisors(&self) -> Option<Vec<i64>> {
        if self.le(&1) {
            return None;
        }
        let mut divisors: Vec<i64> = Vec::new();
 
        let mut index = 1;
        while index * index <= *self {
            if *self % index == 0 {
                divisors.push(index);
                if index != 1 && index * index != *self {
                    divisors.push(*self / index);
                }
            }
            index += 1;
        }
        divisors.push(*self);
        Option::from(divisors)
    }
}

fn main() {
    input! {
        n: usize,
        a:[i64; n]
    }

    let mut min_number = a[0];
    for i in &a {
        min_number = if min_number > *i {
            *i
        } else {
            min_number
        };
    }
    let mut b = Box::new(a);
    b.sort();
    let min_number = b[0];
    let mut pf = min_number.proper_divisors().unwrap();
    pf.sort();
    let mut ans = min_number; 
    for f in pf.iter().rev() {
        let mut sum = 0;
        for i in 0..n {
            if b[i] % f != 0 {
                sum += 1;
            }
            if sum > 1 {
                break;
            }
        }
        if sum == 0 || sum == 1 {
            ans = *f;
            break;
        }
    }

    println!("{}", ans);

}