import std.stdio;
import std.algorithm;
import std.conv;
import std.range;
import std.string;

int gcd(int m, int n) {
	int a = max(m,n);
	int b = min(m,n);
	if (b == 0) return a;
	return gcd(b, a % b);
}

void main() {
	int n = readln.chomp.to!int;
	int[] as = readln.chomp.split(' ').map!(s => s.to!int).array;
	int all_in = as[0];
	int ex = as[0];
	foreach(a; as[1..$]) {
		ex = max(gcd(ex, a), all_in);
		all_in = gcd(all_in, a);
	}
	int ex1 = ex;
	int tmp = as[0];
	as[0] = as[1];
	as[1] = tmp;
	all_in = as[0];
	ex = as[0];
	foreach(a; as[1..$]) {
		ex = max(gcd(ex, a), all_in);
		all_in = gcd(all_in, a);
	}
	writeln(max(ex, ex1));
}
