using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            consoleReader.ReadLineInt32();
            var As = consoleReader.ReadLineSplitInt32();

            return Calc(As);
        }

        int Calc(int[] As)
        {
            switch (As.Length)
            {
                case 1:
                    return As[0];
                case 2:
                    return Math.Max(As[0], As[1]);
                case 3:
                    return Math.Max(Gcd(As[0], As[2]), Math.Max(Gcd(As[0], As[1]), Gcd(As[1], As[2])));
                default:
                    break;
            }

            HashSet<int> skipGcd;

            var gcd = As[0];
            skipGcd = new HashSet<int> { As[1] };

            for (int i = 1; i < As.Length; i++)
            {
                var a = As[i];
                var next = new HashSet<int> { gcd };
                foreach (var item in skipGcd)
                    next.Add(Gcd(a, item));

                gcd = Gcd(gcd, a);
                skipGcd = next;
            }
            skipGcd.Add(gcd);
            return skipGcd.Max();
        }


        public static int Gcd(int a, int b) => a > b ? GcdImpl(a, b) : GcdImpl(b, a);
        private static int GcdImpl(int a, int b) => b == 0 ? a : GcdImpl(b, a % b);

        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader)
        {
            this.consoleReader = consoleReader;
        }
        static void Main() => Console.WriteLine(new Program().Calc());
    }

    public class ConsoleReader
    {
        public virtual string ReadLine() => Console.ReadLine();
        public int ReadLineInt32() => int.Parse(ReadLine());
        public long ReadLineInt64() => long.Parse(ReadLine());
        public ulong ReadLineUInt64() => ulong.Parse(ReadLine());
        public double ReadLineDouble() => double.Parse(ReadLine());
        public string[] ReadLineSplit() => ReadLine().Split().ToArray();
        public int[] ReadLineSplitInt32() => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public long[] ReadLineSplitInt64() => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public ulong[] ReadLineSplitUInt64() => ReadLine().Split().Select(s => ulong.Parse(s)).ToArray();
        public double[] ReadLineSplitDouble() => ReadLine().Split().Select(s => double.Parse(s)).ToArray();

        public IEnumerable<string> RepeatReadLines(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLine();
        }
        public IEnumerable<int> RepeatReadLinesInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineInt32();
        }
        public IEnumerable<string[]> RepeatReadLinesSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineSplit();
        }
    }
    static class DicExt
    {
        public static double GetOrDefault(this Dictionary<int, double> dic, int key)
        {
            double val;
            return dic.TryGetValue(key, out val) ? val : 1;
        }
    }
}


Measured memory_bytes: 30048