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);

				break;

			}

		}

	}

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

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.373352275070857x):
#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; 

    

}
// 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.345109585634211x):
#include<bits/stdc++.h>

#include<string.h>

#define pb push_back

#define all(v) v.begin(),v.end()

#define see(x) cout<<#x<<" : "<<(x)<<endl;

#define ya cout<<"YES"<<endl;

#define no cout<<"NO"<<endl;

#define ff first

#define sc second

typedef long long ll;

using namespace std;



int main()

{

    ios::sync_with_stdio(false);

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

    //freopen("test.txt","r",stdin);

    ll n,ind=0,i,j,ans=0,ev=0,od=0;

    cin>>n;

    vector<ll>v(n);

    for(auto &ii:v)cin>>ii;

    ll l[n+2];

    ll r[n+2];

    l[0]=r[n+1]=0;

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

    {

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

    }

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

    {

        r[i+1]=__gcd(r[i+2],v[i]);

    }

    ans=1;

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

    {

        ans=max(__gcd(l[i-1],r[i+1]),ans);

    }

    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.3435227234168758x):
#include<bits/stdc++.h>

#include<string.h>

#define pb push_back

#define all(v) v.begin(),v.end()

#define see(x) cout<<#x<<" : "<<(x)<<endl;

#define ya cout<<"YES"<<endl;

#define no cout<<"NO"<<endl;

#define ff first

#define sc second

typedef long long ll;

using namespace std;



int main()

{

    ios::sync_with_stdio(false);

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

    //freopen("test.txt","r",stdin);

    ll n,ind=0,i,j,ans=0,ev=0,od=0;

    cin>>n;

    vector<ll>v(n);

    for(auto &ii:v)cin>>ii;

    ll l[n+2];

    ll r[n+2];

    l[0]=r[n+1]=0;

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

    {

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

    }

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

    {

        r[i+1]=__gcd(r[i+2],v[i]);

    }

    ans=1;

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

    {

        ans=max(__gcd(l[i-1],r[i+1]),ans);

    }

    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.3761658631571734x):
#include <iostream>

#include <cstdio>

#include <cmath>

#include<vector>

#include<algorithm>

using namespace std;

const int maxn=1e5+7;

int a[maxn],b[maxn],c[maxn];

int gcd(int x,int y){

	return y?gcd(y,x%y):x;

}

int main(){

	int n;

	cin>>n;

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

	cin>>a[i];

	b[1]=a[1];

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

		b[i]=gcd(b[i-1],a[i]);

	}

	c[n]=a[n];

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

	c[i]=gcd(c[i+1],a[i]);

	}

	int g=0;

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

		g=max(gcd(b[i-1],c[i+1]),g);

	}

	g=max(g,max(c[2],b[n-1]));

	cout<<g;

}
// 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.3745423630079268x):
#include <iostream>

#include <cstdio>

#include <cmath>

#include<vector>

#include<algorithm>

using namespace std;

const int maxn=1e5+7;

int a[maxn],b[maxn],c[maxn];

int gcd(int x,int y){

	return y?gcd(y,x%y):x;

}

int main(){

	int n;

	cin>>n;

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

	cin>>a[i];

	b[1]=a[1];

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

		b[i]=gcd(b[i-1],a[i]);

	}

	c[n]=a[n];

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

	c[i]=gcd(c[i+1],a[i]);

	}

	int g=0;

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

		g=max(gcd(b[i-1],c[i+1]),g);

	}

	g=max(g,max(c[2],b[n-1]));

	cout<<g;

}
// 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.3865391971637593x):
#include <bits/stdc++.h>

using namespace std;

const int maxn=1e5+5;

typedef long long ll;

ll p[maxn], l[maxn], a[maxn];

int main()

{

	int n;

	scanf("%d",&n);

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

	{

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

	}

	p[1]=a[1], l[n]=a[n];

	ll ans=0;

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

	{

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

//		l[n-i+1]=__gcd(l[n-i+2], a[n-i+1]);

	}

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

	{

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

	}

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

	{

		ans = max(ans, __gcd(p[i-1], l[i+1]));

	}

	cout<<max(ans, max(l[2], p[n-1]))<<endl;

}
// 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.3849034593113703x):
#include <bits/stdc++.h>

using namespace std;

const int maxn=1e5+5;

typedef long long ll;

ll p[maxn], l[maxn], a[maxn];

int main()

{

	int n;

	scanf("%d",&n);

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

	{

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

	}

	p[1]=a[1], l[n]=a[n];

	ll ans=0;

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

	{

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

//		l[n-i+1]=__gcd(l[n-i+2], a[n-i+1]);

	}

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

	{

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

	}

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

	{

		ans = max(ans, __gcd(p[i-1], l[i+1]));

	}

	cout<<max(ans, max(l[2], p[n-1]))<<endl;

}
// 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.3745988944488554x):
#include <iostream>

#include <cmath>

#include <algorithm>

using namespace std;

const int maxn = 1e5 + 5;

int a[maxn];

int suml[maxn], sumr[maxn];



int gcd(int x, int y) {

    return y==0?x:gcd(y, x%y);

}



int main(){

    int n;

    cin >> n;

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

        cin >> a[i]; 

    }



    if (n==1) {

        cout << a[1] << endl;

        return 0;

    }



    suml[0] = 0;

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

        suml[i] = gcd(a[i], suml[i-1]);

    }



    sumr[n] = a[n];

    sumr[0] = 0;

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

        sumr[i] = gcd(a[i], sumr[i+1]);

    }



    int ans = max(suml[n-1], sumr[2]);

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

        ans = max(ans, gcd(suml[i-1], sumr[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.372977242895043x):
#include <iostream>

#include <cmath>

#include <algorithm>

using namespace std;

const int maxn = 1e5 + 5;

int a[maxn];

int suml[maxn], sumr[maxn];



int gcd(int x, int y) {

    return y==0?x:gcd(y, x%y);

}



int main(){

    int n;

    cin >> n;

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

        cin >> a[i]; 

    }



    if (n==1) {

        cout << a[1] << endl;

        return 0;

    }



    suml[0] = 0;

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

        suml[i] = gcd(a[i], suml[i-1]);

    }



    sumr[n] = a[n];

    sumr[0] = 0;

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

        sumr[i] = gcd(a[i], sumr[i+1]);

    }



    int ans = max(suml[n-1], sumr[2]);

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

        ans = max(ans, gcd(suml[i-1], sumr[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.3917941703195276x):
#include<stdio.h>

#include<string.h>

#include<math.h>

#include<iostream>

#include<string>

#include<sstream>

#include<algorithm>

#include<map>

#include<set>

#include<queue>

#include<stack>

#include<vector>

using namespace std;

typedef long long ll; 

typedef pair<int, int> P; 

const int mod = 1e9 + 7;

const int N = 2e6 + 5;

struct ed{

	int to, nxt;

}e[N << 1];

int head[N], tot = 1;

void add(int u, int v){

	e[tot].to = v, e[tot].nxt = head[u], head[u] = tot++;

}

ll gcd(ll a, ll b)

{

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

}

ll f[N], h[N], a[N], n, ans;

int  main()

{

	scanf("%lld", &n);

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

	{

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

		if (i)

			f[i] = gcd(f[i - 1], a[i]);

		else

			f[i] = a[i];

	}

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

	{

		if (i == n - 1)

			h[i] = a[i];

		else

			h[i] = gcd(h[i + 1], a[i]);

	}

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

	{

		if (i == 0)

			ans = max(ans, h[i + 1]);

		else if (i == n - 1)

			ans = max(ans, f[n - 2]);

		else

			ans = max(ans, gcd(f[i - 1], h[i + 1]));

	}

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

}
// 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.3901522330329488x):
#include<stdio.h>

#include<string.h>

#include<math.h>

#include<iostream>

#include<string>

#include<sstream>

#include<algorithm>

#include<map>

#include<set>

#include<queue>

#include<stack>

#include<vector>

using namespace std;

typedef long long ll; 

typedef pair<int, int> P; 

const int mod = 1e9 + 7;

const int N = 2e6 + 5;

struct ed{

	int to, nxt;

}e[N << 1];

int head[N], tot = 1;

void add(int u, int v){

	e[tot].to = v, e[tot].nxt = head[u], head[u] = tot++;

}

ll gcd(ll a, ll b)

{

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

}

ll f[N], h[N], a[N], n, ans;

int  main()

{

	scanf("%lld", &n);

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

	{

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

		if (i)

			f[i] = gcd(f[i - 1], a[i]);

		else

			f[i] = a[i];

	}

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

	{

		if (i == n - 1)

			h[i] = a[i];

		else

			h[i] = gcd(h[i + 1], a[i]);

	}

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

	{

		if (i == 0)

			ans = max(ans, h[i + 1]);

		else if (i == n - 1)

			ans = max(ans, f[n - 2]);

		else

			ans = max(ans, gcd(f[i - 1], h[i + 1]));

	}

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

}
// 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.3528314966347927x):
#include <cstdio>

#include <algorithm>

#include <iostream>

#include <vector>

#include <map>

#include <queue>

#include <set>

#include <ctime>

#include <cstring>

#include <cstdlib>

#include <math.h>

using namespace std;

typedef long long ll;

//#define ll long long

const ll N = 2009;

const ll maxn = 1e5 + 20;

const ll mod = 1000000007;

//ll inv[maxn], vis[maxn], dis[maxn], head[maxn];

ll fac[maxn], a[maxn], q[maxn], b[maxn], c[maxn], pre[maxn];

vector<ll> vec;

//typedef pair<ll, ll> p;

//priority_queue<p, vector<p>, greater<p> > m;

ll sum[maxn];

ll max(ll a, ll b) { return a > b ? a : b; }

ll min(ll a, ll b) { return a < b ? a : b; }

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

map<ll, ll> mp;

ll ksm(ll a, ll b)

{

    a %= mod;

    ll ans = 1ll;

    while (b)

    {

        if (b & 1)

            ans = (ans * a) % mod;

        a = (a * a) % mod;

        b >>= 1ll;

    }

    return ans;

}

ll lowbit(ll x)

{

    return x & (-x);

}

int dp[maxn];

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    ll n, ans = 1, x, res;

    cin >> n;

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

        cin >> a[i], mp[a[i]]++;

    sort(a + 1, a + 1 + n);

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

    {

        int fla = 0, res;

        for (ll j = 1; j <= n; j += mp[a[j]])

        {

            if (i == j && mp[a[i]] == 1)

                continue;

            if (!fla)

                fla = 1, res = a[j];

            res = gcd(res, a[j]);

            if (res == 1)

                break;

        }

        ans = max(ans, res);

    }

    cout << ans << endl;

}