// Slower C++ solution:
#include <iostream>

#include<vector>

#include<algorithm>

#include<string>

#include<map>

#include<set>

#include<stack>

#include<queue>

#include<math.h>

using namespace std;

typedef long long ll;

#define int long long

typedef vector<int> VI;

typedef pair<int, int> pii;

#define fore(i,a) for(auto &i:a)

#define REP(i,n) for(int i=0;i<n;i++)

#define eREP(i,n) for(int i=0;i<=n;i++)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)

#define SORT(c) sort((c).begin(),(c).end())

#define rSORT(c) sort((c).rbegin(),(c).rend())

#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))

#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))

#define INF 1000000000

#define LLINF 9223372036854775807

#define mod 1000000007

//vector<vector<int> > dp;

//vector<vector<vector<int> > > vvvi;

//dp=vector<vector<int> >(N, vector<int>(M,0));

//vector<pair<int,int> > v;

//v.push_back(make_pair(x,y));

//priority_queue<int,vector<int>, greater<int> > q2;





int gcd(int a, int b) {//最大公約数

	if (b == 0)return a;

	return gcd(b, a%b);

}



signed main(){

cin.tie(0);

ios::sync_with_stdio(false);



	int N;

	cin >> N;

	VI A(N);

	REP(i, N) {

		cin >> A[i];

	}

	SORT(A);

	VI ret;

	int n = A[0];

	int ans=0;

	for (int i = 1; i*i <= n; ++i)

	{

		if (n%i == 0)

		{

			ret.push_back(i);

			if (i != 1 && i*i != n)

			{

				ret.push_back(n / i);

			}

		}

	}

	ret.push_back(A[0]);

	rSORT(ret);

	REP(i, ret.size()) {

		//cout << ret[i] << endl;

		int cnt = 0;

		REP(j, N) {

			if (A[j] % ret[i] == 0) {

				continue;

			}

			else {

				cnt++;

			}

			if (cnt == 2) {

				//cout << j << " " << i << " " << cnt << endl;

				break;

			}

			

		}

		if (cnt <= 1) {

			ans = max(ans,ret[i]);

		}

		//cout << ans << endl;

	}

	n = A[1];

	VI rret;

	for (int i = 1; i*i <= n; ++i)

	{

		if (n%i == 0)

		{

			rret.push_back(i);

			if (i != 1 && i*i != n)

			{

				rret.push_back(n / i);

			}

		}

	}

	rret.push_back(A[1]);

	rSORT(rret);

	REP(i, rret.size()) {

		//cout << rret[i] << endl;

		int cnt = 0;

		REP(j, N) {

			if (A[j] % rret[i] == 0) {

				continue;

			}

			else {

				cnt++;

			}

			if (cnt == 2) {

				//cout << j << " " << i << " " << cnt << endl;

				break;

			}



		}

		if (cnt <= 1) {

			ans = max(ans, rret[i]);

		}

		//cout << ans << endl;

	}

	cout << ans << endl;

	return 0;

}




// Faster C++ solution for the same problem (measured speedup: 1.3802874781985879x):
#include <iostream>

#include<vector>

#include<algorithm>

#include<string>

#include<map>

#include<set>

#include<stack>

#include<queue>

#include<math.h>

using namespace std;

typedef long long ll;

#define int long long

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef priority_queue<int> PQ;

#define fore(i,a) for(auto &i:a)

#define REP(i,n) for(int i=0;i<n;i++)

#define eREP(i,n) for(int i=0;i<=n;i++)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)

#define SORT(c) sort((c).begin(),(c).end())

#define rSORT(c) sort((c).rbegin(),(c).rend())

#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))

#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))

#define INF 1000000000

#define LLINF 2147483647

#define mod 1000000007

//vector<vector<int> > dp;

//vector<vector<vector<int> > > vvvi;

//dp=vector<vector<int> >(N, vector<int>(M,0));

//vector<pair<int,int> > v;

//v.push_back(make_pair(x,y));

//priority_queue<int,vector<int>, greater<int> > q2;



vector<int> value;

int N;



int gcd(int a, int b) {

	if (b == 0)return a;

	else return gcd(b, a%b);

}



void update(int i, int x) {

	i += N - 1;

	value[i] = x;

	while (i > 0) {

		i = (i - 1) / 2;

		value[i] = gcd(value[i * 2 + 1], value[i * 2 + 2]);

		//cout <<i<<" "<< value[i * 2 + 1] << " " << value[i * 2 + 2] << endl;

	}

}



int query(int a, int b, int k, int l, int r) {

	if (r <= a || b <= l)return 0;

	//cout << " " << k << " "<<l << " " << r << endl;

	if (a <= l && r <= b)return value[k];

	else {

		int c1 = query(a, b, 2 * k + 1, l, (l + r) / 2);

		int c2 = query(a, b, 2 * k + 2, (l + r) / 2,r);

		//cout << a << " " << b << " " << c1 << " " << c2 << endl;

		return gcd(c1, c2);

	}

}





signed main(){

cin.tie(0);

ios::sync_with_stdio(false);



	int n;

	cin >> n;

	N = 1;

	while (N < n)N *= 2;

	value = vector<int>(2 * N - 1);

	REP(i, value.size())value[i] = 0;

	REP(i, n) {

		int a;

		cin >> a;

		update(i,a);

	}

	//REP(i, value.size())cout << value[i]<<" ";

//	cout << endl;

	int ans = 0;

	FOR(i,1, n-1) {

		int cnt = gcd(query(0, i, 0, 0, N), query(i + 1, n, 0, 0, N));

		//cout << 0 << " " << i << " " << query(0, i, 0, 0, N) << endl;

		//cout << i + 1 << " " << n << " " << query(i + 1, n, 0, 0, N) << endl;

		ans = max(ans, cnt);

	}

	ans = max(ans, query(1, n, 0, 0, N));

	ans = max(ans, query(0, n - 1, 0, 0, N));

	cout << ans << endl;

	return 0;

}