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

class Program
{
    static int N;
    static int[] A;

    public static void Main(string[] args)
    {
        N = Input.NextInt();
        A = Input.LineInt();

        var divall = A[0];
        var divnuk = A[0];
        var nuki = false;
        {
            for (int i = 1; i < N; i++)
            {
                var newdivall = (int)MathLib.Gcd(divall, A[i]);
                var newdivnuk = (int)MathLib.Gcd(divnuk, A[i]);
                if (newdivall < divall)
                {
                    if (!nuki)
                    {
                        newdivnuk = divall;
                        nuki = true;
                    }
                    else if (newdivnuk < divall)
                    {
                        newdivnuk = divall;
                    }
                }
                divall = newdivall;
                divnuk = newdivnuk;
            }
        }
        int aaa = A[1];
        {
            for (int i = 2; i < N; i++)
            {
                aaa = (int)MathLib.Gcd(aaa, A[i]);
            }
        }
        Console.WriteLine(Math.Max(aaa, Math.Max(divall, divnuk)));
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


/// <summary>
/// Utilities for prime number.
/// </summary>
public static class PrimeNumber
{
    static readonly long[] seedPrimes =
        {
            2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,
        };
    static readonly long[] seedPrimesSkip3Take8 = seedPrimes.Skip(3).Take(8).ToArray();

    /// <summary>
    /// Check prime number or not.
    /// </summary>
    /// <param name="num">Number to check.</param>
    /// <returns><see langword="true"/> if <paramref name="num"/> is prime number.</returns>
    public static bool IsPrime(long num)
    {
        if (num == 1)
            return false;
        if (seedPrimes.Contains(num))
            return true;
        if (seedPrimes.Any(x => num % x == 0))
            return false;

        long i = 0;
        while (true)
        {
            foreach (var p in seedPrimesSkip3Take8)
            {
                // 30m+2, 30m+3, 30m+4, 30m+5, 30m+6、30m+8、30m+9、30m+12... are not required to divide.
                var primeCandidte = p + i;
                if (primeCandidte > Math.Sqrt(num))
                    return true;
                if (num % (primeCandidte) == 0)
                    return false;
            }
            i += 30;
        }
    }

    /// <summary>
    /// Prime factorization.
    /// </summary>
    /// <param name="n">Number to factorize.</param>
    /// <returns><see cref="IEnumerable{T}"/> of prime numbers.</returns>
    public static IEnumerable<long> EnumeratePrimeFactors(long n)
    {
        while (n > 1)
        {
            long factor = GetFactor(n);
            yield return factor;
            n = n / factor;
        }
    }

    private static readonly int[] seeds357111317 = new int[] { 3, 5, 7, 11, 13, 17 };

    private static long Func(long xx, long nn, int sseed)
    {
        return (seeds357111317[sseed % 6] * xx + sseed) % nn;
    }

    private static long GetFactor(long n, int seed = 1)
    {
        if (n % 2 == 0)
            return 2;
        if (IsPrime(n))
            return n;
        long x = 2;
        long y = 2;
        long d = 1;
        long count = 0;
        while (d == 1)
        {
            count++;
            x = Func(x, n, seed);
            y = Func(Func(y, n, seed), n, seed);
            d = MathLib.Gcd(Math.Abs(x - y), n);
        }
        if (d == n)
            return GetFactor(n, seed + 1);
        return GetFactor(d);
    }
}

public class MathLib
{
    /// <summary>
    /// Calculate greatest common divisor.
    /// </summary>
    /// <param name="a"></param>
    /// <param name="b"></param>
    /// <returns>Greatest common divisor calculated.</returns>
    public static long Gcd(long a, long b)
    {
        return (a < b) ? Gcd(b, a)
             : (b > 0) ? Gcd(b, a % b)
                       : a;
    }

    /// <summary>
    /// Calculate least common multiple.
    /// </summary>
    /// <param name="a"></param>
    /// <param name="b"></param>
    /// <returns>Least common multiple calculated.</returns>
    public static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }

    /// <summary>
    /// Enumerate divisors. The order is <b>not</b> sorted.
    /// </summary>
    /// <param name="n">Number to get divisors.</param>
    /// <returns><paramref name="n"/><see cref="IEnumerable{T}"/> of divisors.</returns>
    public static IEnumerable<int> GetDivisors(int n)
    {
        for (int i = 1; i < (int)Math.Sqrt(n) + 1; i++)
        {
            if ((n % i) == 0)
            {
                yield return i;
                if (i != n / i)
                {
                    yield return n / i;
                }
            }
        }
        yield break;
    }
}

Measured memory_bytes: 26332