using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace SolutionCS
{
    class Program
    {
        static int gcd(int a, int b)
        {
            if (a < b)
            {
                return gcd(b, a);
            }

            while (b != 0)
            {
                int rem = a % b;
                a = b;
                b = rem;
            }

            return a;
        }

        class SegTree
        {
            bool setupDone;
            int elementMax;
            int startIndex;
            int[] value;

            public SegTree(int element_max)
            {
                elementMax = element_max;

                int count = 1;
                while (element_max > count)
                {
                    count *= 2;
                }

                startIndex = count - 1;
                count *= 2;
                count--;

                value = new int[count];
                for (int i = 0; i < count; i++)
                {
                    value[i] = InvalidData();
                }

                setupDone = false;
            }

            public void Set(int index, int valueNew)
            {
                this.value[startIndex + index] = valueNew;

                if (setupDone)
                {
                    // 関係のある箇所だけを更新
                    for (int i = index + startIndex; i > 0; i = (i - 1) / 2)
                    {
                        int parent = (i - 1) / 2;
                        int left = parent * 2 + 1;
                        int right = left + 1;

                        value[parent] = Calc(value[left], value[right]);
                    }
                }
            }

            // 全体を計算する
            public void Build()
            {
                for (int i = startIndex - 1; i >= 0; i--)
                {
                    int left = i * 2 + 1;
                    int right = left + 1;

                    value[i] = Calc(value[left], value[right]);
                }

                setupDone = true;
            }

            public int Query()
            {
                return value[0];
            }


            int InvalidData()
            {
                return 0;// int.MaxValue;
            }

            int Calc(int lv, int rv)
            {
                return gcd(lv, rv);
            }
        }

        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int N = int.Parse(strs[0]);

            strs = Console.ReadLine().Split(' ');

            SegTree st = new SegTree(N);
            int[] value = new int[N];
            for (int i = 0; i < N; i++)
            {
                value[i] = int.Parse(strs[i]);
                st.Set(i,value[i] );
            }
            st.Build();

            int ans = int.MinValue;
            for (int i = 0; i < N; i++)
            {
                int input;
                if (i == 0)
                {
                    input = value[1];
                }
                else
                {
                    input = value[i - 1];
                }

                st.Set(i, input);

                ans = Math.Max(st.Query(), ans);

                st.Set(i, value[i]);
            }

            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 24028