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 C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_BeginnerContest_125
{
    class Program
    {

        static void Main(string[] args)
        {

            int cnt = int.Parse(Console.ReadLine());
            long[] dataRow = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

            Array.Sort(dataRow);

            long data1 = Gcd(dataRow[0], dataRow[cnt - 1]);
            long data2 = Gcd(dataRow[1], dataRow[cnt - 1]);
            long data3 = Gcd(dataRow[0], dataRow[cnt - 2]);

            List<long> dataList = new List<long>();
            dataList.Add(data1);
            if (data1 != data2)dataList.Add(data2);
            if ((data1 != data3)&&(data2 != data3))
            {
                dataList.Add(data3);
            }
            dataList.Sort();

            long ret = 1;
            for (int i = dataList.Count - 1; 0 <= i; i--)
            {
                int ngCnt = 0;
                for(int j = 0; j < cnt; j++)
                {
                    if (0 != dataRow[j] % dataList[i])
                    {
                        ngCnt++;
                    }
                    if (2 <= ngCnt) break;
                }

                if (ngCnt <= 1)
                {
                    ret = dataList[i];
                    break;
                }
            }

            if (0 == ret) ret = 1;

            Console.WriteLine(ret);

        }

        static long Gcd(long a, long b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }


    }
}