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

namespace ProconTemplate
{
    class Doing
    {
        public static void Main(string[] args)
        {
            // Drop
            Console.ReadLine();
            var inputList = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            if(inputList.Length == 2)
            {
                Console.WriteLine(inputList.Max());
                return;
            }

            var duplicationList = inputList
                .GroupBy(i => i)
                .Select(g => new { number = g.Key, dupCount = g.Count()})
                .ToList();

            var alwaysGcd = -1;
            if(duplicationList.Any(x => x.dupCount >= 2))
            {
                // 2回以上登場している数字は必ず使うので計算
                alwaysGcd = Gcd(duplicationList.Where(x => x.dupCount >= 2).Select(x => x.number).ToArray());
            }

            if (alwaysGcd == 1)
            {
                Console.WriteLine(alwaysGcd);
                return;
            }else if(!duplicationList.Any(x => x.dupCount == 1))
            {
                Console.WriteLine(alwaysGcd);
                return;
            }

            // 1回のみの数字はスキップして計算する
            var singleList = duplicationList.Where(x => x.dupCount == 1).Select(x => x.number).ToArray();
            if (singleList.Length <= 1)
            {
                Console.WriteLine(alwaysGcd);
                return;
            }

            var maxInt = int.MinValue;
            for(int skipIndex = 0; skipIndex < singleList.Length; skipIndex++)
            {
                var gcdCache = 0;
                if(alwaysGcd == -1)
                {
                    if(skipIndex == 0)
                    {
                        gcdCache = singleList[1];
                    }
                    else
                    {
                        gcdCache = singleList[0];
                    }
                }
                else
                {
                    gcdCache = alwaysGcd;
                }

                for(int useIndex=0; useIndex < singleList.Length; useIndex++)
                {
                    if(gcdCache == 1)
                    {
                        break;
                    }else if(useIndex == skipIndex)
                    {
                        continue;
                    }
                    if(gcdCache > singleList[useIndex])
                    {
                        gcdCache = Gcd(gcdCache, singleList[useIndex]);
                    }else if(gcdCache < singleList[useIndex])
                    {
                        gcdCache = Gcd(singleList[useIndex], gcdCache);
                    }
                }
                maxInt = Math.Max(maxInt, gcdCache);
            }

            Console.WriteLine(maxInt);
        }

        public static int Gcd(int[] intArray)
        {
            if(intArray.Length == 1)
            {
                return intArray[0];
            }
            var gcdCache = 0;
            if(intArray[0] > intArray[1])
            {
                gcdCache= Gcd(intArray[0], intArray[1]);
            }
            else
            {
                gcdCache = Gcd(intArray[1], intArray[0]);
            }
            for(int index=2; index < intArray.Length; index++)
            {
                if(gcdCache == 1)
                {
                    return 1;
                }

                if(gcdCache > intArray[index])
                {
                    gcdCache = Gcd(gcdCache, intArray[index]);
                }else if(gcdCache < intArray[index])
                {
                    gcdCache = Gcd(intArray[index], gcdCache);
                }
            }

            return gcdCache;
        }

        public static int Gcd(int a, int b)
        {
            if(b <= 0)
            {
                return a;
            }else if(b == 1)
            {
                return 1;
            }else if(a == b)
            {
                return a;
            }
            return Gcd(b, a % b);
        }
    }
}


Measured memory_bytes: 28508