stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

#include<math.h>

#include<stdlib.h>

#include<string>

#include<vector>

#include<map>



using namespace std;



#define INF (1<<30)



int n;

int a[100001];



vector<int> enum_div(int n)//nの約数を列挙

{

	vector<int> ret;

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

	{

			if(n%i == 0)

			{

				ret.push_back(i);

				ret.push_back(n/i);

			}

	}

	return ret;

}



int main(){

	cin >> n;

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

		cin >> a[i];

	}

	vector<int> list = enum_div(a[0]);

	int ans = 0;

	for(int i = 0;i < list.size();i++){

		int target = list[i];

		int amount = 0;

		for(int j = 0;j < n;j++){

			if(a[j]%target==0)amount++;

		}

		// cout << amount << endl;

		if(amount == n || amount == n-1)ans = max(ans,target);

	}

	list = enum_div(a[1]);

	for(int i = 0;i < list.size();i++){

		int target = list[i];

		int amount = 0;

		for(int j = 0;j < n;j++){

			if(a[j]%target==0)amount++;

		}

		if(amount == n || amount == n-1)ans = max(ans,target);

	}

    cout << ans << endl;

}

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

#include<math.h>

#include<stdlib.h>

#include<string>

#include<vector>

#include<map>

#include<algorithm>



using namespace std;



#define INF (1<<30)



int n;

int a[100001];

int gcdl[100001];

int gcdr[100001];



int main(){

	cin >> n;

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

		cin >> a[i];

	}

	gcdl[0] = 0;

	gcdr[0] = 0;

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

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

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

	}

	int ans = 1;

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

		int now = __gcd(gcdl[i],gcdr[n-i-1]);

		ans = max(ans, now);

	}

	cout << ans << endl;

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

#include<math.h>

#include<stdlib.h>

#include<string>

#include<vector>

#include<map>

#include<algorithm>



using namespace std;



#define INF (1<<30)



int n;

int a[100001];

int dp[100001][2];



int dpsolve(){

	random_shuffle(a, a+n);

	fill_n(*dp,100001*2,-1);

	for(int d = n-1;d != -1;d--){

		for(int skip = 0;skip < 2;skip++){

			if(d == n-1){

				// if(skip==0){//まだ何も飛ばしてない

				// 	return a[d];

				// }else{

				// 	return a[d];

				// }

				dp[d][skip] = a[d];

				continue;

			}

			int ans = 0;

			ans = max(ans, __gcd(dp[d+1][skip], a[d]));//選ぶ

			if(skip == 0){

				ans = max(ans, dp[d+1][1]);//スキップする

			}

			dp[d][skip] = ans;

		}

	}

	return dp[0][0];

}



int main(){

	cin >> n;

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

		cin >> a[i];

	}

	int ans = 0;

	for(int i = 0;i < 5;i++){

		ans = max(ans, dpsolve());

	}

	cout << ans << endl;

}

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

#include<math.h>

#include<stdlib.h>

#include<string>

#include<vector>

#include<map>

#include<algorithm>



using namespace std;



#define INF (1<<30)



int n;

int a[100001];

int gcdl[100001];

int gcdr[100001];



int main(){

	cin >> n;

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

		cin >> a[i];

	}

	gcdl[0] = 0;

	gcdr[0] = 0;

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

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

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

	}

	int ans = 1;

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

		int now = __gcd(gcdl[i],gcdr[n-i-1]);

		ans = max(ans, now);

	}

	cout << ans << endl;

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

using namespace std;

typedef long long ll;

#define P pair<ll,ll>

#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)

#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)

#define TO(x,t,f) ((x)?(t):(f))

#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9

#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted

#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted

#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted

#define REV(x) (reverse(x.begin(),x.end())) //reverse

ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}

ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu

#define NEXTP(x) next_permutation(x.begin(),x.end())

const ll INF=1e18+7;

const ll MOD=1e9+7;



vector<ll> enum_div(int n){

	vector<ll> ret;

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

			if(n%i == 0){

				ret.push_back(i);

				ret.push_back(n/i);

			}

	}

	return ret;

}





int main(){

	ll N,ans=0;

	cin >> N;

	vector<ll> a(N);

	FOR(i,0,N)cin>>a[i];

	SORT(a);

	FOR(i,0,2){

		for(auto y:enum_div(a[i])){

			ll k = 0;

			FOR(j,0,N){

				if(a[j]%y==0)k++;

			}

			if(k>=N-1){

				ans = max(ans,y);

			}

		}

	}

	cout << ans << endl;

}

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

using namespace std;

int gcd(int a,int b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}



class Seg_Tree{//gcd

public:

	vector<int> dat;

	int n;

	void initsize(int n0){

		int k=1;

		while(1){

			if(n0<=k){

				n=k;

				dat.resize(2*n-1);

				for(int i=0;i<2*n-1;i++)dat[i]=1;

				break;

			}

			k*=2;

		}

	}



	//to sg[i]  x

	void update(int i,int x){

		i += n-1;

		dat[i] = x;

		while(i>0){

			i = (i-1) / 2;

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

		}

	}



	//gcd[a,b)

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

		if(r<=a || b<=l)return dat[a+n-1];

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

		else{

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

			int vr = query0(a,b,k*2+2,(l+r)/2,r);

			return gcd(vl,vr);

		}

	}



	//return gcd [a,b)

	int query(int a,int b){

		return query0(a,b,0,0,n);

	}

};



int main(){

	int N;

	cin >> N;

	Seg_Tree sg;

	sg.initsize(N);

	for(int i=0;i<N;i++){

		int k;

		cin >> k;

		sg.update(i,k);

	}



	int ans = max(sg.query(1,N),sg.query(0,N-1));

	for(int i=1;i<N-1;i++){

		int p = gcd(sg.query(0,i),sg.query(i+1,N));

		ans = max(ans,p);

	}



	cout << ans << endl;

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

using namespace std;

typedef long long ll;



const int N = 1e5 + 5, mod = 1e9 + 7;



int a[N], dp[N][2], n;



int solve(int i, int taken)

{

    if (i == n - 1)

    {

        if (taken)

            return a[i];

        return 0;

    }

    if (dp[i][taken] != -1)

        return dp[i][taken];

    int ans = 0;

    if (taken)

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

    else

        ans = max(__gcd(solve(i + 1, 0), a[i]), solve(i + 1, 1));

    return dp[i][taken] = ans;

}



int main()

{

    //ios::sync_with_stdio(false);cin.tie(nullptr);ios_base::sync_with_stdio(false);

    cin >> n;

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

        cin >> a[i];

    memset(dp, -1, sizeof dp);

    cout << solve(0, 0);

    return 0;

}

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

using namespace std;

#define PI          acos(-1)

#define INF         100000000

#define sc(n)       scanf("%d",&n);

#define ssc(n)      scanf("%s",n);

#define lsc(n)      scanf("%lld",&n);

#define dsc(n)      scanf("%lf",&n);

#define csc(n)       scanf("%c",&n);

#define LL          long long int

#define UI          unsigned int

#define ULL         unsigned long long int

#define DB          double

#define pii         pair<int,int>

#define VI          vector<int>

#define MII         map<int,int>

#define PB          push_back

#define MP          make_pair

#define M(mx,a)     mx=max(mx,a)

#define IT          ::iterator

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

#define mems(a,b)   memset(a,b,sizeof(a))

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

#define IN(n,aa)    for(i=0;i<n;i++)scanf("%d",&aa[i]);

#define PNT(n,aa)   for(i=0;i<n;i++)printf("%lld ",aa[i]);

#define mod         1000000007

#define NUM         10000009

#define NUM2        1000000000





int main()

{

    int T=1,QQ=0;

    //cin >> T ;

    while(T--)

    {

        int n,i,j,k,g;

        cin >> n ;

        int aa[n],left[n],right[n];

        for(i=0;i<n;i++)sc(aa[i]);

        g=aa[0];

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

        {

            g=__gcd(g,aa[i]);

            left[i]=g;

        }

        g=aa[n-1];

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

        {

            g=__gcd(g,aa[i]);

            right[i]=g;

        }

        g=max(right[1],left[n-2]);

        for(i=1;i<n-1;i++)g=max(g,__gcd(left[i-1],right[i+1]));

        cout << g ;

    }

}



//printf("Case %d: ",++QQ);
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



const int N = 1e5 + 5, mod = 1e9 + 7;



int a[N], dp[N][2], n;



int solve(int i, int taken)

{

    if (i == n - 1)

    {

        if (taken)

            return a[i];

        return 0;

    }

    if (dp[i][taken] != -1)

        return dp[i][taken];

    int ans = 0;

    if (taken)

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

    else

        ans = max(__gcd(solve(i + 1, 0), a[i]), solve(i + 1, 1));

    return dp[i][taken] = ans;

}



int main()

{

    //ios::sync_with_stdio(false);cin.tie(nullptr);ios_base::sync_with_stdio(false);

    cin >> n;

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

        cin >> a[i];

    memset(dp, -1, sizeof dp);

    cout << solve(0, 0);

    return 0;

}

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

using namespace std;

int main()

{

    int t,a,p,c=0;

    vector<int>v,v1;

    cin>>t;

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

    {

        cin>>a;

        v.push_back(a);

    }

    sort(v.begin(),v.end());

    p=sqrt(v[0]);

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

    {

        if(v[0]%i==0)

        {

            v1.push_back(i);

            v1.push_back(v[0]/i);

        }

    }

    p=sqrt(v[t-1]);

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

    {

        if(v[t-1]%i==0)

        {

            v1.push_back(i);

            v1.push_back(v[t-1]/i);

        }

    }

    sort(v1.begin(),v1.end());

    reverse(v1.begin(),v1.end());

    for(int i=0; i<v1.size(); i++)

    {

        c=0;

        for(int j=0; j<t; j++)

        {

            if(v[j]%v1[i]!=0)

            {

                c++;

                if(c==2)

                    break;

            }

        }

        if(c==1 || c==0)

        {

            cout<<v1[i]<<endl;

            break;

        }

    }

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

using namespace std;

typedef long long ll;



const int N = 1e5 + 5, mod = 1e9 + 7;



int a[N], dp[N][2], n;



int solve(int i, int taken)

{

    if (i == n - 1)

    {

        if (taken)

            return a[i];

        return 0;

    }

    if (dp[i][taken] != -1)

        return dp[i][taken];

    int ans = 0;

    if (taken)

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

    else

        ans = max(__gcd(solve(i + 1, 0), a[i]), solve(i + 1, 1));

    return dp[i][taken] = ans;

}



int main()

{

    //ios::sync_with_stdio(false);cin.tie(nullptr);ios_base::sync_with_stdio(false);

    cin >> n;

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

        cin >> a[i];

    memset(dp, -1, sizeof dp);

    cout << solve(0, 0);

    return 0;

}

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

using namespace std;

int main()

{

    int n;

    cin>>n;

    long long int ar[n+2],a1[n+2],a2[n+2],s;

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

    {

        cin>>ar[i];

    }

    a1[0]=0;a2[n+1]=0;

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

    {

        a1[i]=__gcd(a1[i-1],ar[i]);

    }

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

    {

        a2[i]=__gcd(a2[i+1],ar[i]);

    }

    s=0;

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

    {

       s=max(s,__gcd(a1[i-1],a2[i+1]));

    }

    cout<<s<<endl;

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

using namespace std;

int main()

{

    int t,a,p,c=0;

    vector<int>v,v1;

    cin>>t;

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

    {

        cin>>a;

        v.push_back(a);

    }

    sort(v.begin(),v.end());

    p=sqrt(v[0]);

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

    {

        if(v[0]%i==0)

        {

            v1.push_back(i);

            v1.push_back(v[0]/i);

        }

    }

    p=sqrt(v[t-1]);

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

    {

        if(v[t-1]%i==0)

        {

            v1.push_back(i);

            v1.push_back(v[t-1]/i);

        }

    }

    sort(v1.begin(),v1.end());

    reverse(v1.begin(),v1.end());

    for(int i=0; i<v1.size(); i++)

    {

        c=0;

        for(int j=0; j<t; j++)

        {

            if(v[j]%v1[i]!=0)

            {

                c++;

                if(c==2)

                    break;

            }

        }

        if(c==1 || c==0)

        {

            cout<<v1[i]<<endl;

            break;

        }

    }

}


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

using namespace std;

int main()

{

    int n;

    cin>>n;

    long long int ar[n+2],a1[n+2],a2[n+2],s;

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

    {

        cin>>ar[i];

    }

    a1[0]=0;a2[n+1]=0;

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

    {

        a1[i]=__gcd(a1[i-1],ar[i]);

    }

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

    {

        a2[i]=__gcd(a2[i+1],ar[i]);

    }

    s=0;

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

    {

       s=max(s,__gcd(a1[i-1],a2[i+1]));

    }

    cout<<s<<endl;

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

using namespace std;

typedef long long ll;



const int N = 1e5 + 5, mod = 1e9 + 7;



int a[N], dp[N][2], n;



int solve(int i, int taken)

{

    if (i == n - 1)

    {

        if (taken)

            return a[i];

        return 0;

    }

    if (dp[i][taken] != -1)

        return dp[i][taken];

    int ans = 0;

    if (taken)

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

    else

        ans = max(__gcd(solve(i + 1, 0), a[i]), solve(i + 1, 1));

    return dp[i][taken] = ans;

}



int main()

{

    //ios::sync_with_stdio(false);cin.tie(nullptr);ios_base::sync_with_stdio(false);

    cin >> n;

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

        cin >> a[i];

    memset(dp, -1, sizeof dp);

    cout << solve(0, 0);

    return 0;

}

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

using namespace std;

int n;

int a[100005]; 

int gcd1[100005];

int gcd2[100005];

int main()

{

	scanf("%d",&n);

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

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

	

	gcd1[1]=a[1];

	gcd2[n]=a[n];

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

	    gcd1[i]=__gcd(gcd1[i-1],a[i]);//cout<<gcd1[i]<<" ";

	//cout<<endl;

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

	    gcd2[i]=__gcd(gcd2[i+1],a[i]);//cout<<gcd2[i]<<" ";

	//cout<<endl;

	gcd1[0]=gcd2[2];

	gcd2[n+1]=gcd1[n-1];

	int ans=0;

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

		ans=max(ans,__gcd(gcd1[i-1],gcd2[i+1]));

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

	return 0;

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

using namespace std;

int main()

{

    int t,a,p,c=0;

    vector<int>v,v1;

    cin>>t;

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

    {

        cin>>a;

        v.push_back(a);

    }

    sort(v.begin(),v.end());

    p=sqrt(v[0]);

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

    {

        if(v[0]%i==0)

        {

            v1.push_back(i);

            v1.push_back(v[0]/i);

        }

    }

    p=sqrt(v[t-1]);

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

    {

        if(v[t-1]%i==0)

        {

            v1.push_back(i);

            v1.push_back(v[t-1]/i);

        }

    }

    sort(v1.begin(),v1.end());

    reverse(v1.begin(),v1.end());

    for(int i=0; i<v1.size(); i++)

    {

        c=0;

        for(int j=0; j<t; j++)

        {

            if(v[j]%v1[i]!=0)

            {

                c++;

                if(c==2)

                    break;

            }

        }

        if(c==1 || c==0)

        {

            cout<<v1[i]<<endl;

            break;

        }

    }

}


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

using namespace std;

int n;

int a[100005]; 

int gcd1[100005];

int gcd2[100005];

int main()

{

	scanf("%d",&n);

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

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

	

	gcd1[1]=a[1];

	gcd2[n]=a[n];

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

	    gcd1[i]=__gcd(gcd1[i-1],a[i]);//cout<<gcd1[i]<<" ";

	//cout<<endl;

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

	    gcd2[i]=__gcd(gcd2[i+1],a[i]);//cout<<gcd2[i]<<" ";

	//cout<<endl;

	gcd1[0]=gcd2[2];

	gcd2[n+1]=gcd1[n-1];

	int ans=0;

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

		ans=max(ans,__gcd(gcd1[i-1],gcd2[i+1]));

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

	return 0;

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

#include <bits/stdc++.h>

using namespace std;

using ll = int64_t;

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順



int main() {

    int N;

    cin >> N;

    vector<ll> A(N);

    ll prev;

    bool same = true;

    rep(i,N) {

        cin >> A.at(i);

        if (i == 0) prev = A[0];

        else if (prev != A[i]) {

            same = false;

        }

        prev = A[i];

    }

    if (same) {

        cout << A[0] << endl;

        return 0;

    }

    ll a = A[0];

    ll b = A[1];

    set<ll> div;

    for (int i = 1; i < (int)sqrt(max(a,b)) + 1; i++) {

        if (a % i == 0) {div.insert(i); if (a / i != i) div.insert(a/i);}

        if (b % i == 0) {div.insert(i); if (b / i != i) div.insert(b/i);}

    }

    set<ll> res; 

    for (auto x : div) {

        int cnt = 0;

        rep(i, N) if (A[i] % x == 0)  cnt++;

        if (cnt > N - 2) res.insert(x);

    }

    cout << *rbegin(res) << endl;

}

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

#include <bits/stdc++.h>

using namespace std;

using ll = int64_t;

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順



ll gcd(ll a, ll b) {

    if (a == 0) return b;

    else if (b == 0) return a;

    return gcd(b, a % b);

}



int main() {

    int N;

    cin >> N;

    vector<ll> A(N+1, 0);

    ll prev;

    bool same = true;

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

        cin >> A.at(i);

        if (i == 1) prev = A[1];

        else if (prev != A[i]) {

            same = false;

        }

        prev = A[i];

    }

    /*

    if (same) {

        cout << A[1] << endl;

        return 0;

    }

    */

    vector<ll> LEFT(N+1,0);

    vector<ll> RIGHT(N+2,0);

    for (int i = 1; i <= N; i++) LEFT[i] = gcd(LEFT[i - 1], A[i]);

    for (int i = N; i >= 1; i--) RIGHT[i] = gcd(A[i], RIGHT[i+1]);

    ll ma = 0;

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

       ma = max(ma, gcd(LEFT[i-1], RIGHT[i+1])); 

    }

    cout << ma << endl;

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

#include<algorithm>

#include<vector>

#include<cstdio>

using namespace std;



static const int Max = 100000;



long long gcd(long long a, long long b){

    long long tmp;

    while( b != 0){

        tmp = b;

        b = a % b;

        a = tmp;

    }

    return a;

}



int main(){

    int n;

    cin >> n;

    vector<long long> v;

    long long l[Max] = {0}, r[Max] = {0};

    long long t, ans = 0;

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

        cin >> t;

        v.push_back(t);

    }

    sort(v.begin(), v.end());

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

        if(i == 1){

            l[i] = v[i-1];

            r[n-1-i] = v[n-i];

        }

        else{

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

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

        }

    }

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

        if(i == 0) ans = r[i];

        else if(i == n-1){

            if(l[i] > ans) ans = l[i];

        }else{

            if(ans < gcd(l[i], r[i])){

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

            }

        }

    }

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

    return 0;

}

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

using namespace std;

typedef long long ll;



int main(){

    int N; cin >> N;

    vector<ll> A(N);

    for(int i = 0; i < N; i++) cin >> A[i];

    vector<ll> left(N), right(N);

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

        if(i == 1){

            left[i] = A[0];

            right[N-i-1] = A[N-1];

        }

        else{

            left[i] = __gcd(left[i-1], A[i-1]);

            right[N-i-1] = __gcd(right[N-1 -(i-1)], A[N-i]);

        }

    }

    ll MAX = 0;

    for(int i = 0; i < N; i++){

        if(i == 0) MAX = max(right[i],MAX);

        else if(i == N - 1) MAX = max(left[i],MAX);

        else MAX = max(MAX, __gcd(left[i],right[i]));

    }

    cout << MAX << endl; 

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



using namespace std;



vector<int> Divis(int n) {

	vector<int> divs;

	

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

		if (n % i == 0) divs.push_back(i);

	}

	

	for (int i = divs.size() - 1; i >= 0 ; i--) {

		if (n / divs[i] != divs[i]) divs.push_back(n / divs[i]);

	}

	

	divs.push_back(n);

	

	return divs;

}



int main() {

	int n; cin >> n;

	vector<int> a(n);

	for (int i = 0; i < n; i++) cin >> a[i];

	

	vector<vector<int> > divs(n);

	for (int i = 0; i < min(2,n); i++) divs[i] = Divis(a[i]);

	

	set<int> mults;

	map<int, int> mp;

	

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

		for (int j = 0; j < divs[i].size(); j++) {

			mults.insert(divs[i][j]);

		}

	}

	

	int gcd = 0, close = 0;

	

	for (auto i = mults.begin(); i != mults.end(); i++) {

	    int cnt = 0;

	    for(int j = 0; j < n; j++){

	        if(a[j] % (*i) == 0) cnt += 1;

	    }

		if (cnt == n) gcd = (*i);

		if (cnt == n - 1) close = (*i);

	}

	

	if (gcd != 0 || close != 0) {

		if (gcd > close) cout << gcd;

		else cout << close;

	}

	else cout << 1;

	

	return 0;

}

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

using namespace std;

#define ll	    long long

#define vi      vector <ll>

#define vii     vector <pair<int,int>>

#define ii      pair<int,int>

#define loop(n)	for(ll i=0;i<n;i++)

#define pb      push_back

const ll mod=1e9+7;

void fast();



int main()

{

    fast();

    int n;

    cin>>n;

    int a[n];

    loop(n)

        cin>>a[i];

    sort(a,a+n);

    vi prefix(n+1,a[0]),suffix(n+1,a[n-1]);

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

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

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

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

    ll res=max(prefix[n-2],suffix[1]);

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

        res=max(res,__gcd(prefix[i-1],suffix[i+1]));

    cout<<res;

}

void fast(){

std::ios_base::sync_with_stdio(0);

    cin.tie(NULL);

    cout.tie(NULL);

}

/*



*/