import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(int[]);
    int g = AS[0];
    foreach (a; AS[1..$]) g = gcd(g, a);
    foreach (ref a; AS) a = a / g;

    int h = AS[0];
    bool flg;
    foreach (a; AS[1..$]) {
        auto h_ = gcd(h, a);
        if (h_ == 1) {
            if (flg) {
                h = 1;
                break;
            }
            flg = true;
        } else {
            h = h_;
        }
    }

    int i = AS[$-1];
    flg = false;
    foreach (a; AS[0..$-1]) {
        auto i_ = gcd(i, a);
        if (i_ == 1) {
            if (flg) {
                i = 1;
                break;
            }
            flg = true;
        } else {
            i = i_;
        }
    }
    writeln(g * max(h, i));
}