stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int maxn=1e5+5;

int a[maxn];

vector<int> fac[5];

void gf(int a,int num)

{

	fac[num].push_back(1);

	fac[num].push_back(a);

	int i;

	for(i=2;i*i<a;i++)

		if(a%i==0)

		{

			fac[num].push_back(i);

			fac[num].push_back(a/i);

		}

	if(i*i==a)

		fac[num].push_back(1);

	sort(fac[num].begin(),fac[num].end());

}

void fl()

{

	freopen(".in","r",stdin);

	freopen(".out","w",stdout);

}

int main()

{

//  fl();

	int n;

	scanf("%d",&n);

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

	{

		scanf("%d",&a[i]);

	}

	gf(a[1],1);

	gf(a[2],2);

	int ans=-maxn;

	for(int t=1;t<=2;t++)

	{

		for(int i=fac[t].size()-1;i>=0;i--)

		{

			int tmp=fac[t][i],num=0;

			bool sign=true;

			for(int j=1;j<=n;j++)

			{

				if(a[j]%tmp!=0)

					num++;

				if(num>1)

				{

					sign=false;

					break;

				}

			}

			if(sign)

				ans=max(ans,tmp);

		}

	}

	printf("%d\n",ans);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3450439710960977x):
/*

	"We know what we are, but know not what we may be."

*/



#include <bits/stdc++.h>



using namespace std;

using ll = long long;



const int N = 2e5 + 3;

const int M = 1e6 + 7;

const long long MOD = 1e9 + 7;

const long long INF = 1e18 + 9;

const int SM = 1e3 + 5;

const int logN = 20, BL = 400;

const double EPS = 3e-16;



/*

	"You never know how strong you are until being strong is the only choice you have."

*/



int main(){

//  freopen(".in", "r", stdin);

//  freopen(".out", "w", stdout);

    ios_base::sync_with_stdio(false);

    cin.tie(0), cout.tie(0);



/*

	"With self-discipline most anything is possible."

*/

	

	long long n; cin >> n;



	vector<long long> a(n + 1), pref(n + 2), suff(n + 2);	

	for(long long i = 1; i <= n; i++){

		cin >> a[i];

	}

	

	for(long long i = 1; i <= n; i++){

		pref[i] = __gcd(pref[i - 1], a[i]);

	}

	for(long long i = n; i > 0; i--){

		suff[i] = __gcd(suff[i + 1], a[i]);

	}

	

	long long ans = 0;

	for(long long i = 1; i <= n; i++){

		ans = max(ans, __gcd(pref[i - 1], suff[i + 1]));

	}

	

	cout << ans;

	return 0;

}



/*

	"Reach for it. Push yourself as far as you can."

*/
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int maxn=1e5+5;

int a[maxn];

vector<int> fac[5];

void gf(int a,int num)

{

	fac[num].push_back(1);

	fac[num].push_back(a);

	int i;

	for(i=2;i*i<a;i++)

		if(a%i==0)

		{

			fac[num].push_back(i);

			fac[num].push_back(a/i);

		}

	if(i*i==a)

		fac[num].push_back(1);

	sort(fac[num].begin(),fac[num].end());

}

void fl()

{

	freopen(".in","r",stdin);

	freopen(".out","w",stdout);

}

int main()

{

//  fl();

	int n;

	scanf("%d",&n);

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

	{

		scanf("%d",&a[i]);

	}

	gf(a[1],1);

	gf(a[2],2);

	int ans=-maxn;

	for(int t=1;t<=2;t++)

	{

		for(int i=fac[t].size()-1;i>=0;i--)

		{

			int tmp=fac[t][i],num=0;

			bool sign=true;

			for(int j=1;j<=n;j++)

			{

				if(a[j]%tmp!=0)

					num++;

				if(num>1)

				{

					sign=false;

					break;

				}

			}

			if(sign)

			{

				ans=max(ans,tmp);

				break;

			}

		}

	}

	printf("%d\n",ans);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3434571862860107x):
/*

	"We know what we are, but know not what we may be."

*/



#include <bits/stdc++.h>



using namespace std;

using ll = long long;



const int N = 2e5 + 3;

const int M = 1e6 + 7;

const long long MOD = 1e9 + 7;

const long long INF = 1e18 + 9;

const int SM = 1e3 + 5;

const int logN = 20, BL = 400;

const double EPS = 3e-16;



/*

	"You never know how strong you are until being strong is the only choice you have."

*/



int main(){

//  freopen(".in", "r", stdin);

//  freopen(".out", "w", stdout);

    ios_base::sync_with_stdio(false);

    cin.tie(0), cout.tie(0);



/*

	"With self-discipline most anything is possible."

*/

	

	long long n; cin >> n;



	vector<long long> a(n + 1), pref(n + 2), suff(n + 2);	

	for(long long i = 1; i <= n; i++){

		cin >> a[i];

	}

	

	for(long long i = 1; i <= n; i++){

		pref[i] = __gcd(pref[i - 1], a[i]);

	}

	for(long long i = n; i > 0; i--){

		suff[i] = __gcd(suff[i + 1], a[i]);

	}

	

	long long ans = 0;

	for(long long i = 1; i <= n; i++){

		ans = max(ans, __gcd(pref[i - 1], suff[i + 1]));

	}

	

	cout << ans;

	return 0;

}



/*

	"Reach for it. Push yourself as far as you can."

*/
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int maxn=1e5+5;

int a[maxn];

vector<int> fac[5];

void gf(int a,int num)

{

	fac[num].push_back(1);

	fac[num].push_back(a);

	int i;

	for(i=2;i*i<a;i++)

		if(a%i==0)

		{

			fac[num].push_back(i);

			fac[num].push_back(a/i);

		}

	if(i*i==a)

		fac[num].push_back(1);

	sort(fac[num].begin(),fac[num].end());

}

void fl()

{

	freopen(".in","r",stdin);

	freopen(".out","w",stdout);

}

int main()

{

//  fl();

	int n;

	scanf("%d",&n);

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

	{

		scanf("%d",&a[i]);

	}

	gf(a[1],1);

	gf(a[2],2);

	int ans=-maxn;

	for(int t=1;t<=2;t++)

	{

		for(int i=fac[t].size()-1;i>=0;i--)

		{

			int tmp=fac[t][i],num=0;

			bool sign=true;

			for(int j=1;j<=n;j++)

			{

				if(a[j]%tmp!=0)

					num++;

				if(num>1)

				{

					sign=false;

					break;

				}

			}

			if(sign)

				ans=max(ans,tmp);

		}

	}

	printf("%d\n",ans);

	return 0;

}


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

#include <bits/stdc++.h>

using namespace std;



#define pb push_back

#define F first

#define S second

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



using ll = long long;

using ld = long double;

using ul = unsigned long long;

using ii = pair<int, int>;

#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define ReadFile            freopen("input.in","r",stdin)

#define WriteFile           freopen("output.txt","w",stdout)

const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;

const ld EPS = 1e-7;

double Pi=acos(-1);

const ld rad=Pi/180.0;

ll power(ll x, ll y, ll p)

{

    ll res = 1;

    while (y > 0)

    {

        if (y & 1)

            res = (res*x) % p;

        y = y>>1;

        x = (x*x) % p;

    }

    return res;

}

ll nCr (ll n,ll m)

{

        return(m == 0)?1:n*nCr(n-1,m-1)/m;

}

/*****************************************************/



int gcd(int a, int b) {

  return b ? gcd(b, a%b) : a;

}



int main() {

  int n;

  cin >> n;

  vector<int> a(n);

  rep(i,n) cin >> a.at(i);

  vector<int> l(n), r(n);

  rep(i,n-1) l[i+1] = gcd(l[i], a[i]);

  for(int i = n-1; i >= 1; i--) r[i-1] = gcd(r[i], a[i]);

  int ans = 1;

  rep(i,n) ans = max(ans, gcd(l[i], r[i]));

  cout << ans << endl;





    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int maxn=1e5+5;

int a[maxn];

vector<int> fac[5];

void gf(int a,int num)

{

	fac[num].push_back(1);

	fac[num].push_back(a);

	int i;

	for(i=2;i*i<a;i++)

		if(a%i==0)

		{

			fac[num].push_back(i);

			fac[num].push_back(a/i);

		}

	if(i*i==a)

		fac[num].push_back(1);

	sort(fac[num].begin(),fac[num].end());

}

void fl()

{

	freopen(".in","r",stdin);

	freopen(".out","w",stdout);

}

int main()

{

//  fl();

	int n;

	scanf("%d",&n);

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

	{

		scanf("%d",&a[i]);

	}

	gf(a[1],1);

	gf(a[2],2);

	int ans=-maxn;

	for(int t=1;t<=2;t++)

	{

		for(int i=fac[t].size()-1;i>=0;i--)

		{

			int tmp=fac[t][i],num=0;

			bool sign=true;

			for(int j=1;j<=n;j++)

			{

				if(a[j]%tmp!=0)

					num++;

				if(num>1)

				{

					sign=false;

					break;

				}

			}

			if(sign)

			{

				ans=max(ans,tmp);

				break;

			}

		}

	}

	printf("%d\n",ans);

	return 0;

}


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

#include <bits/stdc++.h>

using namespace std;



#define pb push_back

#define F first

#define S second

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



using ll = long long;

using ld = long double;

using ul = unsigned long long;

using ii = pair<int, int>;

#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define ReadFile            freopen("input.in","r",stdin)

#define WriteFile           freopen("output.txt","w",stdout)

const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;

const ld EPS = 1e-7;

double Pi=acos(-1);

const ld rad=Pi/180.0;

ll power(ll x, ll y, ll p)

{

    ll res = 1;

    while (y > 0)

    {

        if (y & 1)

            res = (res*x) % p;

        y = y>>1;

        x = (x*x) % p;

    }

    return res;

}

ll nCr (ll n,ll m)

{

        return(m == 0)?1:n*nCr(n-1,m-1)/m;

}

/*****************************************************/



int gcd(int a, int b) {

  return b ? gcd(b, a%b) : a;

}



int main() {

  int n;

  cin >> n;

  vector<int> a(n);

  rep(i,n) cin >> a.at(i);

  vector<int> l(n), r(n);

  rep(i,n-1) l[i+1] = gcd(l[i], a[i]);

  for(int i = n-1; i >= 1; i--) r[i-1] = gcd(r[i], a[i]);

  int ans = 1;

  rep(i,n) ans = max(ans, gcd(l[i], r[i]));

  cout << ans << endl;





    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int maxn=1e5+5;

int a[maxn];

vector<int> fac[5];

void gf(int a,int num)

{

	fac[num].push_back(1);

	fac[num].push_back(a);

	int i;

	for(i=2;i*i<a;i++)

		if(a%i==0)

		{

			fac[num].push_back(i);

			fac[num].push_back(a/i);

		}

	if(i*i==a)

		fac[num].push_back(1);

	sort(fac[num].begin(),fac[num].end());

}

void fl()

{

	freopen(".in","r",stdin);

	freopen(".out","w",stdout);

}

int main()

{

//  fl();

	int n;

	scanf("%d",&n);

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

	{

		scanf("%d",&a[i]);

	}

	gf(a[1],1);

	gf(a[2],2);

	int ans=-maxn;

	for(int t=1;t<=2;t++)

	{

		for(int i=fac[t].size()-1;i>=0;i--)

		{

			int tmp=fac[t][i],num=0;

			bool sign=true;

			for(int j=1;j<=n;j++)

			{

				if(a[j]%tmp!=0)

					num++;

				if(num>1)

				{

					sign=false;

					break;

				}

			}

			if(sign)

				ans=max(ans,tmp);

		}

	}

	printf("%d\n",ans);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.357672790468264x):
#include <bits/stdc++.h>

using namespace std;



#define fr(i,n) _back

#define pb	push_back

#define eb	emplace_back

#define mk	make_pair

#define fi	first

#define se	second

#define endl	'\n'



typedef long long ll;

typedef pair<int,int> ii;

typedef vector<ii> vii;

const int INF = 0x3f3f3f3f;

const double PI = acos(-1.0);

const int T = 1e5 + 2;

int v[T];

int l[T];

int r[T];



int main() {

    ios_base::sync_with_stdio(false);

    int n; cin >> n;

    int ans = 0;



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

        cin >> v[i];

        l[i] = v[i];

        if(i > 1) l[i] = __gcd(l[i],l[i-1]);

    }



    for(int i = n; i >= 1; i--) {

        r[i] = v[i];

        if(i < n) r[i] = __gcd(r[i],r[i+1]);

    }



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

        ans = max(ans, __gcd(i-1 >= 1? l[i-1] : r[i+1], i+1 <= n? r[i+1] : l[i-1]));



    cout << ans << endl;



    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int maxn=1e5+5;

int a[maxn];

vector<int> fac[5];

void gf(int a,int num)

{

	fac[num].push_back(1);

	fac[num].push_back(a);

	int i;

	for(i=2;i*i<a;i++)

		if(a%i==0)

		{

			fac[num].push_back(i);

			fac[num].push_back(a/i);

		}

	if(i*i==a)

		fac[num].push_back(1);

	sort(fac[num].begin(),fac[num].end());

}

void fl()

{

	freopen(".in","r",stdin);

	freopen(".out","w",stdout);

}

int main()

{

//  fl();

	int n;

	scanf("%d",&n);

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

	{

		scanf("%d",&a[i]);

	}

	gf(a[1],1);

	gf(a[2],2);

	int ans=-maxn;

	for(int t=1;t<=2;t++)

	{

		for(int i=fac[t].size()-1;i>=0;i--)

		{

			int tmp=fac[t][i],num=0;

			bool sign=true;

			for(int j=1;j<=n;j++)

			{

				if(a[j]%tmp!=0)

					num++;

				if(num>1)

				{

					sign=false;

					break;

				}

			}

			if(sign)

			{

				ans=max(ans,tmp);

				break;

			}

		}

	}

	printf("%d\n",ans);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3560711070978477x):
#include <bits/stdc++.h>

using namespace std;



#define fr(i,n) _back

#define pb	push_back

#define eb	emplace_back

#define mk	make_pair

#define fi	first

#define se	second

#define endl	'\n'



typedef long long ll;

typedef pair<int,int> ii;

typedef vector<ii> vii;

const int INF = 0x3f3f3f3f;

const double PI = acos(-1.0);

const int T = 1e5 + 2;

int v[T];

int l[T];

int r[T];



int main() {

    ios_base::sync_with_stdio(false);

    int n; cin >> n;

    int ans = 0;



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

        cin >> v[i];

        l[i] = v[i];

        if(i > 1) l[i] = __gcd(l[i],l[i-1]);

    }



    for(int i = n; i >= 1; i--) {

        r[i] = v[i];

        if(i < n) r[i] = __gcd(r[i],r[i+1]);

    }



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

        ans = max(ans, __gcd(i-1 >= 1? l[i-1] : r[i+1], i+1 <= n? r[i+1] : l[i-1]));



    cout << ans << endl;



    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int maxn=1e5+5;

int a[maxn];

vector<int> fac[5];

void gf(int a,int num)

{

	fac[num].push_back(1);

	fac[num].push_back(a);

	int i;

	for(i=2;i*i<a;i++)

		if(a%i==0)

		{

			fac[num].push_back(i);

			fac[num].push_back(a/i);

		}

	if(i*i==a)

		fac[num].push_back(1);

	sort(fac[num].begin(),fac[num].end());

}

void fl()

{

	freopen(".in","r",stdin);

	freopen(".out","w",stdout);

}

int main()

{

//  fl();

	int n;

	scanf("%d",&n);

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

	{

		scanf("%d",&a[i]);

	}

	gf(a[1],1);

	gf(a[2],2);

	int ans=-maxn;

	for(int t=1;t<=2;t++)

	{

		for(int i=fac[t].size()-1;i>=0;i--)

		{

			int tmp=fac[t][i],num=0;

			bool sign=true;

			for(int j=1;j<=n;j++)

			{

				if(a[j]%tmp!=0)

					num++;

				if(num>1)

				{

					sign=false;

					break;

				}

			}

			if(sign)

				ans=max(ans,tmp);

		}

	}

	printf("%d\n",ans);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3729117889921105x):
#include <bits/stdc++.h>

#define FAST_IO ios::sync_with_stdio(false);cin.tie(0)

#define MAX_V 200005



using namespace std;



int p[MAX_V], s[MAX_V], v[MAX_V];



//GCD rapido

int gcd(int a, int b)

{

    while (b) b ^= a ^= b ^= a %= b;

    return a;

}



int main()

{

    FAST_IO;

    int n;

    scanf("%d", &n);

    scanf("%d", v+0);



    //Le o primeiro numero

    p[0] = v[0];



    //Le os demais numeros acumulando o GCD da esquerda pra direita (p)refix

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

        scanf("%d", v+i);

        p[i] = gcd(v[i], p[i-1]);

    }



    //Acumula GCD da direita pra esquerda (s)uffix

    s[n-1] = v[n-1];

    for (int i = n-2; i >= 0; i--)

        s[i] = gcd(v[i], s[i+1]);



    //Calcula o GCD de todos os numeros menos o i-esimo.

    //Faz-se isso calculando o gcd do prefixo até i-1 com o sufixo até i+1

    int ans = max(s[1], p[n-2]);

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

        ans = max(gcd(p[i-1], s[i+1]), ans);



    //A resposta será o maior gcd encontrado. Na pratica esta sendo substituido um numero pelo proprio gcd

    printf("%d\n", ans);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int maxn=1e5+5;

int a[maxn];

vector<int> fac[5];

void gf(int a,int num)

{

	fac[num].push_back(1);

	fac[num].push_back(a);

	int i;

	for(i=2;i*i<a;i++)

		if(a%i==0)

		{

			fac[num].push_back(i);

			fac[num].push_back(a/i);

		}

	if(i*i==a)

		fac[num].push_back(1);

	sort(fac[num].begin(),fac[num].end());

}

void fl()

{

	freopen(".in","r",stdin);

	freopen(".out","w",stdout);

}

int main()

{

//  fl();

	int n;

	scanf("%d",&n);

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

	{

		scanf("%d",&a[i]);

	}

	gf(a[1],1);

	gf(a[2],2);

	int ans=-maxn;

	for(int t=1;t<=2;t++)

	{

		for(int i=fac[t].size()-1;i>=0;i--)

		{

			int tmp=fac[t][i],num=0;

			bool sign=true;

			for(int j=1;j<=n;j++)

			{

				if(a[j]%tmp!=0)

					num++;

				if(num>1)

				{

					sign=false;

					break;

				}

			}

			if(sign)

			{

				ans=max(ans,tmp);

				break;

			}

		}

	}

	printf("%d\n",ans);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3712921277623096x):
#include <bits/stdc++.h>

#define FAST_IO ios::sync_with_stdio(false);cin.tie(0)

#define MAX_V 200005



using namespace std;



int p[MAX_V], s[MAX_V], v[MAX_V];



//GCD rapido

int gcd(int a, int b)

{

    while (b) b ^= a ^= b ^= a %= b;

    return a;

}



int main()

{

    FAST_IO;

    int n;

    scanf("%d", &n);

    scanf("%d", v+0);



    //Le o primeiro numero

    p[0] = v[0];



    //Le os demais numeros acumulando o GCD da esquerda pra direita (p)refix

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

        scanf("%d", v+i);

        p[i] = gcd(v[i], p[i-1]);

    }



    //Acumula GCD da direita pra esquerda (s)uffix

    s[n-1] = v[n-1];

    for (int i = n-2; i >= 0; i--)

        s[i] = gcd(v[i], s[i+1]);



    //Calcula o GCD de todos os numeros menos o i-esimo.

    //Faz-se isso calculando o gcd do prefixo até i-1 com o sufixo até i+1

    int ans = max(s[1], p[n-2]);

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

        ans = max(gcd(p[i-1], s[i+1]), ans);



    //A resposta será o maior gcd encontrado. Na pratica esta sendo substituido um numero pelo proprio gcd

    printf("%d\n", ans);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int maxn=1e5+5;

int a[maxn];

vector<int> fac[5];

void gf(int a,int num)

{

	fac[num].push_back(1);

	fac[num].push_back(a);

	int i;

	for(i=2;i*i<a;i++)

		if(a%i==0)

		{

			fac[num].push_back(i);

			fac[num].push_back(a/i);

		}

	if(i*i==a)

		fac[num].push_back(1);

	sort(fac[num].begin(),fac[num].end());

}

void fl()

{

	freopen(".in","r",stdin);

	freopen(".out","w",stdout);

}

int main()

{

//  fl();

	int n;

	scanf("%d",&n);

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

	{

		scanf("%d",&a[i]);

	}

	gf(a[1],1);

	gf(a[2],2);

	int ans=-maxn;

	for(int t=1;t<=2;t++)

	{

		for(int i=fac[t].size()-1;i>=0;i--)

		{

			int tmp=fac[t][i],num=0;

			bool sign=true;

			for(int j=1;j<=n;j++)

			{

				if(a[j]%tmp!=0)

					num++;

				if(num>1)

				{

					sign=false;

					break;

				}

			}

			if(sign)

				ans=max(ans,tmp);

		}

	}

	printf("%d\n",ans);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3748235692038742x):
//#pragma GCC optimize("Ofast")

//#pragma GCC target("avx,avx2,fma")



#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)

typedef long long int lli;

typedef pair<int, int> pi;

#define oset tree<pi, null_type,greater<pi>, rb_tree_tag,tree_order_statistics_node_update>





int main()

{

    int n;

    cin >> n;

    int a[n+2];

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

        cin >> a[i];

    }

    int left[n+2]={0}, right[n+2]={0};

    int gc = 0;

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

        gc = __gcd(a[i], gc);

        left[i] = gc;

    }

    gc = 0;

    for(int i=n; i>0; i--){

        gc = __gcd(gc, a[i]);

        right[i] = gc;

    }

    int mx = 0;

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

        mx = max(mx, __gcd(left[i-1], right[i+1]));

    }

    cout << mx << '\n';



    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int maxn=1e5+5;

int a[maxn];

vector<int> fac[5];

void gf(int a,int num)

{

	fac[num].push_back(1);

	fac[num].push_back(a);

	int i;

	for(i=2;i*i<a;i++)

		if(a%i==0)

		{

			fac[num].push_back(i);

			fac[num].push_back(a/i);

		}

	if(i*i==a)

		fac[num].push_back(1);

	sort(fac[num].begin(),fac[num].end());

}

void fl()

{

	freopen(".in","r",stdin);

	freopen(".out","w",stdout);

}

int main()

{

//  fl();

	int n;

	scanf("%d",&n);

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

	{

		scanf("%d",&a[i]);

	}

	gf(a[1],1);

	gf(a[2],2);

	int ans=-maxn;

	for(int t=1;t<=2;t++)

	{

		for(int i=fac[t].size()-1;i>=0;i--)

		{

			int tmp=fac[t][i],num=0;

			bool sign=true;

			for(int j=1;j<=n;j++)

			{

				if(a[j]%tmp!=0)

					num++;

				if(num>1)

				{

					sign=false;

					break;

				}

			}

			if(sign)

			{

				ans=max(ans,tmp);

				break;

			}

		}

	}

	printf("%d\n",ans);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.373201652595167x):
//#pragma GCC optimize("Ofast")

//#pragma GCC target("avx,avx2,fma")



#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)

typedef long long int lli;

typedef pair<int, int> pi;

#define oset tree<pi, null_type,greater<pi>, rb_tree_tag,tree_order_statistics_node_update>





int main()

{

    int n;

    cin >> n;

    int a[n+2];

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

        cin >> a[i];

    }

    int left[n+2]={0}, right[n+2]={0};

    int gc = 0;

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

        gc = __gcd(a[i], gc);

        left[i] = gc;

    }

    gc = 0;

    for(int i=n; i>0; i--){

        gc = __gcd(gc, a[i]);

        right[i] = gc;

    }

    int mx = 0;

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

        mx = max(mx, __gcd(left[i-1], right[i+1]));

    }

    cout << mx << '\n';



    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int maxn=1e5+5;

int a[maxn];

vector<int> fac[5];

void gf(int a,int num)

{

	fac[num].push_back(1);

	fac[num].push_back(a);

	int i;

	for(i=2;i*i<a;i++)

		if(a%i==0)

		{

			fac[num].push_back(i);

			fac[num].push_back(a/i);

		}

	if(i*i==a)

		fac[num].push_back(1);

	sort(fac[num].begin(),fac[num].end());

}

void fl()

{

	freopen(".in","r",stdin);

	freopen(".out","w",stdout);

}

int main()

{

//  fl();

	int n;

	scanf("%d",&n);

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

	{

		scanf("%d",&a[i]);

	}

	gf(a[1],1);

	gf(a[2],2);

	int ans=-maxn;

	for(int t=1;t<=2;t++)

	{

		for(int i=fac[t].size()-1;i>=0;i--)

		{

			int tmp=fac[t][i],num=0;

			bool sign=true;

			for(int j=1;j<=n;j++)

			{

				if(a[j]%tmp!=0)

					num++;

				if(num>1)

				{

					sign=false;

					break;

				}

			}

			if(sign)

				ans=max(ans,tmp);

		}

	}

	printf("%d\n",ans);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3749743695828567x):
#include <bits/stdc++.h>

#define ull unsigned long long

#define ll long long

#define endl '\n'

#define pb push_back

#define mp make_pair

#define mod 1000000007

#define line cout<<"----------------------------------"<<endl

#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);

#define filein freopen("input.txt","r",stdin)

#define fileout freopen("output.txt","w",stdout)

using namespace std;

const ll mx=200009;

int ara[mx]; 

int pre[mx],suf[mx]; 

int main()

{

    int n; 

    cin>>n; 

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

    {

        cin>>ara[i]; 

        pre[i]=__gcd(pre[i-1],ara[i]);

    }

    for(int i=n;i>=1;i--)

    {

        suf[i]=__gcd(suf[i+1],ara[i]);

    }

    int maxi=0; 

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

    {

        maxi=max(maxi,__gcd(pre[i-1],suf[i+1]));

    }

    cout<<maxi<<endl; 

    

}