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.3512355246698629x):
#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;

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

using namespace std;



int main() {

    int N;

    cin >> N;

    vector<int> A(N);

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

  

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

    int MIN1 = A[0];

    int MIN2 = A[1];

    //cout << MIN1 << " " << MIN2 << endl;

    int ans = 0;

    vector<int> yaku = {};

    for (int i = 1; i * i <= MIN1; i++) {

        if (MIN1 % i == 0) {

            yaku.push_back(i);

            yaku.push_back(MIN1 / i);

        }

    }



    //for (int i = 0; i < yaku.size(); i++) cout << yaku[i] << endl;

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

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

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

        int cnt = 0;

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

            if (A[j] % yaku[i] == 0) cnt++;

        }

        if (cnt >= N - 1) {

            ans = yaku[i];

            break;

        }

    }

  

    yaku = {};

    for (int i = 1; i * i <= MIN2; i++) {

        if (MIN2 % i == 0) {

            yaku.push_back(i);

            yaku.push_back(MIN2 / i);

        }

    }



    //for (int i = 0; i < yaku.size(); i++) cout << yaku[i] << endl;

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

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

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

        int cnt = 0;

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

            if (A[j] % yaku[i] == 0) cnt++;

        }

        if (cnt >= N - 1) {

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

            break;

        }

    }

    cout << ans << endl;

}

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

using namespace std;



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

	if (b == 0) return a;

	return gcd(b, a % b);

}



int main() {

    int N;

    cin >> N;

    vector<long long> A(N);

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

  

    vector<long long> L(N + 1);

    vector<long long> R(N + 1);

    L[0] = 0;

    R[N] = 0;

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

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



    long long ans = 0;

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

        if (ans < gcd(L[i], R[i + 1])) ans = gcd(L[i], R[i + 1]);

    }

    cout << ans << endl;

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

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

using namespace std;

typedef long long ll;

typedef pair<ll,ll> P;

const int MOD = 1000000007;



int main() {

  int n;

  cin >> n;

  map<int,int>mp;

  vector<int>a(n);

  rep(i,n) cin >> a[i];

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

  rep(i,2){

    for(int j=1;j*j<=a[i];j++){

      if(a[i]%j==0){

        mp[j]++;

        mp[a[i]/j]++;

      }

    }

  }

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

    for(auto j:mp){

      if(a[i]%j.first==0){

        mp[j.first]++;

      }

    }

  }

  int ans=1;

  for(auto p:mp){  

    if(p.second==n || p.second==n-1){

      if(ans<p.first)ans=p.first;

    }

  }

  

  cout << ans << endl;

  

}


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

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

using namespace std;

typedef unsigned long long ull;

typedef long long ll;

const ll INF=1e18;

const int MOD=1e9+7;

const double pi=acos(-1);

ll gcd(ll x, ll y){

  if(x%y==0)return y;

  else return gcd(y,x%y);

}

int main(){

  int n;

  cin >> n;

  vector<ll>a(n);

  rep(i,n) cin >> a[i];

  vector<ll>lg(n);

  vector<ll>rg(n);

  lg[0]=a[0];

  rg[0]=a[n-1];

  rep(i,n-1){

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

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

  }

  ll ans=0;

  rep(i,n){

    if(i==0)ans=max(ans,rg[n-2]);

    else if(i==n-1)ans=max(ans,lg[n-2]);

    else ans=max(ans,gcd(lg[i-1],rg[n-i-2]));

  }

  cout << ans << endl;

            

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

using namespace std;

using ll = long long;

int gcd(int a, int b)

{

    if(b == 0) return a;

    return gcd(b, a%b);

}



int main()

{

    int n;

    cin >> n;

    vector<int> a(n);

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

    {

        cin >> a[i];

    }

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

    int ans = 1;

    int m1 = a[n-1];

    int m2 = a[n-2];

    vector<int> m1p;

    vector<int> m2p;

    m1p.push_back(m1);

    m2p.push_back(m2);

    for(int i = 2; i * i <= m1; i++)

    {

        if(m1 % i == 0)

        {

            m1p.push_back(i);

            m1p.push_back(m1 / i);

        }

    }

    for(int i = 2; i * i <= m2; i++)

    {

        if(m2 % i == 0)

        {

            m2p.push_back(i);

            m2p.push_back(m2 / i);

        }

    }



    int i = m1;

    int cnt = 2;

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

    {

        int cand = m1p[i];

        int tmp = 0;

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

        {

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

        }

        if(tmp <= 1)

        {

            ans = max(ans, cand);

        }

    }

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

    {

        int cand = m2p[i];

        int tmp = 0;

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

        {

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

        }

        if(tmp <= 1)

        {

            ans = max(ans, cand);

        }

    }

    cout << ans << endl;

}




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

using namespace std;

int gcd(int a, int b)

{

    if(b == 0) return a;

    return gcd(b, a%b);

}

int main()

{

    int n;

    cin >> n;

    vector<int> a(n);

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

    {

        cin >> a[i];

    }

    vector<int> l(n+1);

    vector<int> r(n+1);

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

    {

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

    }

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

    {

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

    }



    int ans = 0;

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

    {

        int g = gcd(l[i], r[n-1-i]);

        ans = max(ans, g);

    }

    cout << ans << endl;

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

using namespace std;

int a[100010];

int res[100010];

int cnt[100010];

int main(){

	int n;

	cin>>n;

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

	sort(a,a+n);

	int x=a[0];

	int y=a[1];

	int c=0;

	int b=0;

	for(int i=1;i*i<=x;i++){

		if(x%i==0){

			res[c]=i;

			c++;

			res[c]=x/i;

			c++;

		}

	}

	sort(res,res+c);

	for(int i=1;i*i<=y;i++){

		if(y%i==0){

			cnt[b]=i;

			b++;

			cnt[b]=y/i;

			b++;

		}

	}

	sort(cnt,cnt+b);

	int ans=-1;

	int ans2=-1;

	for(int i=c-1;i>=0;i--){

		int ans3=0;

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

			if(a[j]%res[i]!=0){

				ans3++;

			}

		}

		if(ans3==0||ans3==1){

			ans=res[i];

			break;

		}

	}

	for(int i=b-1;i>=0;i--){

		int ans3=0;

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

			if(a[j]%cnt[i]!=0){

				ans3++;

			}

		}

		if(ans3==0||ans3==1){

			ans2=cnt[i];

			break;

		}

	}

	cout<<max(ans,ans2)<<endl;

	return 0;

}

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

using namespace std;

int a[100010];

int res[100010];

int cnt[100010];

int solve(int n){

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

		cin>>a[i];

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

	}

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

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

	}

	int ans=1;

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

		ans=max(ans,__gcd(res[i-1],cnt[i+1]));

	}

	return ans;

}

int main(){

	int n;

	cin>>n;

	cout<<solve(n)<<endl;

	return 0;

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

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

#define PI 3.14159265359

#define INF 1000100100

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

typedef long long ll;

#define P pair<int, int>

using namespace std;



int main(){

    int n; cin >> n;

    vector<int> a(n);

    rep(i,n) cin >> a[i];

    vector<P> prime2;

    vector<P> prime1;

    

    int now=a[0]; int p1l=0;

    for(int i=2; i<=(int)sqrt(a[0])+1; i++){

        if(now%i==0){

            prime1.push_back(P(i,1));

            now/=i;

            p1l++;

        }

        while(now%i==0){

            prime1[p1l-1].second++;

            now/=i;

        }

    }

    if(now!=1) prime1.push_back(P(now,1));



    now=a[1]; int p2l=0;

    for(int i=2; i<=(int)sqrt(a[1])+1; i++){

        if(now%i==0){

            prime2.push_back(P(i,1));

            now/=i;

            p2l++;

        }

        while(now%i==0){

            prime2[p2l-1].second++;

            now/=i;

        }

    }

    if(now!=1) prime1.push_back(P(now,1));



    int pl=prime1.size();

    rep(i,prime2.size()){

        bool ex=false;

        rep(j,pl){

            if(prime2[i].first==prime1[j].first){

                prime1[j].second=max(prime1[j].second,prime2[i].second);

                ex=true;

                break;

            }

        }

        if(ex==false) prime1.push_back(prime2[i]);

    }



    vector<int> primes;

    rep(i,prime1.size()){

        rep(j,prime1[i].second) primes.push_back(prime1[i].first);

    }

    sort(all(primes));

    int prl=primes.size();

   //rep(i,prl) cout << primes[i] << endl;

    vector<int> check(prl,-1);

    rep(i,n){

        rep(j,prl){

            if(a[i]%primes[j]==0) a[i]/=primes[j];

            else if(check[j]==-1) check[j]=i;

            else check[j]=-2;

        }

    }



    int ans=1;

    rep(i,check.size()){

        if(check[i]==-1) ans*=primes[i];

    }

    int fac=1;

    rep(j,n){

        int tmp=1;

  	    rep(i,check.size()){

            if(check[i]==j) tmp*=primes[i];

        }

        fac=max(fac,tmp);

    }



    cout << fac*ans << endl;

    return 0;

}



//rate1379

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

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

#define PI 3.14159265359

#define INF 1000100100

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

typedef long long ll;

#define P pair<int, int>

using namespace std;



int gcd(int a,int b){

    if(a<b) swap(a,b);

    int r=a%b;

    while(r!=0){

        a=b;

        b=r;

        r=a%b;

    }

    return b;

}



int main(){

    int n; cin >> n;

    vector<int> a(n);

    rep(i,n) cin >> a[i];

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

    l[0]=a[0];

    for(int i=1; i<n; i++) l[i]=gcd(l[i-1],a[i]);

    r[n-1]=a[n-1];

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

    int ans=0;

    rep(i,n){

        if(i==0) ans=max(ans,r[1]);

        else if(i==n-1) ans=max(ans,l[n-2]);

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

    }

    cout << ans << endl;

return 0;

}
// Slower C++ solution:
// C - GCD on Blackboard

#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>;

#define MAX 100000



int N;

vi A(MAX+1), L(MAX+1), R(MAX+1), M(MAX+1);



int gcd(int a, int b){

	if(a<b) swap(a,b);

	while(b){ int r = a%b; a = b; b = r; }

	return a;

}



int main(){

	cin>>N;

	for(int n=1; n<=N; ++n) cin>>A[n];

	for(int n=0; n<N; ++n) L[n+1] = gcd(L[n], A[n]);

	for(int n=N; n>=0; --n) R[n] = gcd(R[n+1], A[n]);

	for(int n=1; n<=N; ++n) M[n] = gcd(L[n], R[n+1]);

	int maxi = 0;

	for(int n=1; n<=N; ++n) maxi = max(maxi,M[n]);

	cout<< maxi <<endl;

}

// Faster C++ solution for the same problem (measured speedup: 2.5972163277033613x):
// C - GCD on Blackboard

#include <bits/stdc++.h>

using namespace std;



int gcd(int a, int b){

	if(a<b) swap(a,b);

	while(b){int r =a%b; a=b; b=r;}

	return a;

}



int main(){

	int N; cin>>N;

	vector<int> A(N), L(N), R(N), M(N);



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

	for(int n=0; n<=N-1-1; ++n) L[n+1] = gcd(L[n], A[n]);

	for(int n=N-1-1; n>=0; --n) R[n] = gcd(R[n+1], A[n+1]);

	for(int n=0; n<N; ++n) M[n] = gcd(L[n], R[n]);



	int maxi = 0;

	for(int n=0; n<N; ++n) maxi = max(maxi,M[n]);

	cout<< maxi <<endl;

}
// Slower C++ solution:
// C - GCD on Blackboard

#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>;

#define MAX 100000



int N;

vi A(MAX+1), L(MAX+1), R(MAX+1), M(MAX+1);



int gcd(int a, int b){

	if(a<b) swap(a,b);

	while(b){ int r = a%b; a = b; b = r; }

	return a;

}



int main(){

	cin>>N;

	for(int n=1; n<=N; ++n) cin>>A[n];

	for(int n=0; n<N; ++n) L[n+1] = gcd(L[n], A[n]);

	for(int n=N; n>=0; --n) R[n] = gcd(R[n+1], A[n]);

	for(int n=1; n<=N; ++n) M[n] = gcd(L[n], R[n+1]);

	int maxi = 0;

	for(int n=1; n<=N; ++n) maxi = max(maxi,M[n]);

	cout<< maxi <<endl;

}

// Faster C++ solution for the same problem (measured speedup: 2.597125701702558x):
// C - GCD on Blackboard

#include <bits/stdc++.h>

using namespace std;



int gcd(int a, int b){

	if(a<b) swap(a,b);

	while(b){int r =a%b; a=b; b=r;}

	return a;

}



int main(){

	int N; cin>>N;

	vector<int> A(N), L(N), R(N);



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

	for(int n=0; n<=N-1-1; ++n) L[n+1] = gcd(L[n], A[n]);

	for(int n=N-1-1; n>=0; --n) R[n] = gcd(R[n+1], A[n+1]);



	int maxi = 0;

	for(int n=0; n<N; ++n) maxi = max(maxi, gcd(L[n], R[n]));

	cout<< maxi <<endl;

}
// Slower C++ solution:
#define rep(i, m, n) for(int i = m; i < n; i++)

#define repM(i, m, n) for(int i = n-1; i>=m; i--)

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

typedef long long ll; using namespace std;

//typedef pair<int,int> pii;

// d = distance(lower_bound(all(x)), upper_bound(all(x)));

int INF = 1e9;

int m = 1e9+7;

#include <iostream>

#include <vector>

#include <cmath>

#include <algorithm>

#include <queue>



int main(){

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

  sort(a, a+N);

  //rep(i, 0, N) a[i] = (i==0) ? a[i] : a[i] - a[i-1];

  //sort(a, a+N);

  vector<int> r[2];

  rep(i, 0, 2) {

    for(int j=1; j*j <= a[i]; j++) {

      if (a[i] % j == 0) {r[i].push_back(j); r[i].push_back(a[i]/j);}

    }

    //cout << r[i].size() << endl;

  }

  int an=1;

  rep(i, 0, 2) {

    for (int k:r[i]){

      int dm=0; //cout << k << " ";

      rep(j, 0, N) {

        if (a[j] % k) dm++;

        if (dm==2) break;

      }

      if (dm<=1) an = max(an, k);

    }

  }

  cout << an << endl;

}

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

using namespace std;



int gcd(int x, int y) {if (y == 0) return x; return gcd(y,x%y);}



int main(){

  int n; cin>>n;

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

  int b[n]; b[0] = a[0];

  int c[n]; c[n-1] = a[n-1];

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

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

  }

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

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

  }

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

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

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

  }

  cout<<an<<endl;

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

using namespace std;

const int maxn = 100005;

int GCD(int a, int b){ return b ? GCD(b, a % b) : a; }

int A[maxn],l[maxn], r[maxn];

int main(){

	int N; cin >> N;

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

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

		l[i+1] = GCD(l[i], A[i]);

	}

	for(int i = N-1; i >= 0; --i){

		r[i] = GCD(r[i+1], A[i]);

	}

 

	int max = 0;

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

		int ll = l[i], rr = r[i+1];

		int g = GCD(ll, rr);

		if(max < g) max = g;

	}

	cout << max << endl;

	return 0;

}

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

#include<cmath>

#include<algorithm>

using namespace std;

int n,a[1000005],ans=1;

int main()

{

    scanf("%d",&n);

    for(int i=1;i<=n;i++) scanf("%d",&a[i]);

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

    for(int i=a[2];i>=2;i--)

    {

        int t=0;

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

        {

            if(a[j]%i!=0) t++;

            if(t>=2) break;

        }

        if(t<=1)

        {

            ans=i;

            break;

        }

    }

    printf("%d",ans);

    return 0;

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

#include <iomanip>

#include <algorithm>

#include <cmath>

#include <queue>

#include <list>

#include <string>

using namespace std;

 

typedef long long ll;

typedef pair<int, int> P;

const int MOD = 998244353;

 

int gcd(int a, int b){

  if(b == 0) return a;

  return gcd(b, a%b);

}

 

int main()

{

  int N,keep,count;

  bool finish = false;

  ll A[100000],i,k,secmin,min;

  cin >> N;

  cin >> A[0] >> A[1];

  min = std::min(A[0],A[1]);

  secmin = max(A[0],A[1]);

  vector<int> minl;

  vector<int> minsl;

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

    cin >> A[i];

    if(A[i] < min) {

      secmin = min;

      min = A[i];

    }else if(A[i] < secmin){

      secmin = A[i];

    }

  }

  for(i=1;i<=sqrt(min);i++){

    if(min % i == 0){

      minl.push_back(i);

      minl.push_back(min/i);

    }

  }

  for(i=1;i<=sqrt(secmin);i++){

    if(secmin % i == 0){

      minsl.push_back(i);

      minsl.push_back(secmin/i);

    }

  }

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

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

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

      count = 0;

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

        if(A[j]%minl[i] == 0) count++;

      }

      if(count >= N-1){

        i = minl[i];

          break;

      }

    }

  for(k=minsl.size()-1;k>=0;k--){

    count = 0;

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

      if(A[j]%minsl[k] == 0) count++;

    }

    if(count >= N-1){

      k = minsl[k];

      break;

    }

  }

  cout << max(k,i);

}


// Faster C++ solution for the same problem (measured speedup: 1.3903806547201487x):
#pragma region template

#include "bits/stdc++.h"

using namespace std;

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

const long long MOD = 1e9 + 7, MAX = LLONG_MAX, larg = 1e5, INF = -1e9;

long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;

typedef long long ll;

typedef pair<ll, ll> Pa;



ll gcd(ll a, ll b) {

	if (b == 0) return a;

	return gcd(b, a % b);

}



ll arr[100000];

ll _left[100000];

ll _right[100000];

int main() {

	cin >> N;

	rep(i, N) {

		cin >> arr[i];

	}

	_left[0] = arr[0];

	_right[N - 1] = arr[N - 1];

	rep(i, N - 1) {

		_left[i + 1] = gcd(_left[i], arr[i + 1]);

		_right[N - i - 2] = gcd(_right[N - i - 1], arr[N - i - 2]);

	}

	ll maxv = _right[1];

	rep(i, N - 2) {

		maxv = max(maxv, gcd(_left[i], _right[i + 2]));

	}

	maxv = max(maxv, _left[N - 2]);

	cout << maxv;

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

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

using namespace std;



typedef long long ll;



ll gcd(ll x, ll y) {

    if (y == 0) return x;

    return gcd(y, x % y);

}



int main() {

    int N;

    cin >> N;

    vector<int> A(N);

    map<int, int> mp;

    rep(i, N) cin >> A[i];

    rep(i, 2) {

        for (int j = 1; j * j <= A[i]; j++) {

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

                mp[j]++;

                mp[A[i] / j]++;

            }

        }

    }

    //for (auto i : mp) cout << i.first << " " << i.second << endl;

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

        for (auto j : mp) {

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

                mp[j.first]++;

            }

        }

    }

    int ans = 1, b = 1;

    for (auto i : mp) {

        if (i.second == N) ans = max(ans, i.first);

        if (i.second == N - 1) ans = max(ans, i.first);

    }

    cout << ans << endl;

    //for (auto i : mp) cout << i.first << " " << i.second << endl;

}

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

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

using namespace std;



using ll = long long;



ll gcd(ll x, ll y) {

    if (y == 0) return x;

    return gcd(y, x % y);

}



int main() {

    int N;

    cin >> N;

    vector<ll> A(N), l(N), r(N);

    rep(i, N) cin >> A[i];

    l[0] = A[0];

    rep(i, N - 1) l[i + 1] = gcd(l[i], A[i + 1]);

    r[0] = A[N - 1];

    rep(i, N - 1) r[i + 1] = gcd(r[i], A[N - 2 - i]);

    ll ans = max(l[N - 2], r[N - 2]);

    rep(i, N - 2) {

        ans = max(ans, gcd(l[i], r[N - 3 - i]));

    }

    cout << ans << "\n";

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

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



using namespace std;



typedef long long ll;



int max_N = 100005;





int gcd(int a, int b){

	if(b == 0) return a;

	return gcd(b, a % b);

}



void addDivs(set<int> &st, int t){

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

		if(t % i == 0){

			st.insert(i);

			st.insert(t / i);

		}

	}

}



int main()

{

	cin.tie(0);

	ios::sync_with_stdio(false);



	int N;

	cin >> N;



	vector<int> A(N, 0);

	rep(i, N) cin >> A[i];



	set<int> st;

	addDivs(st, A[0]);

	addDivs(st, A[1]);



	int ans = 1;



	for(int x : st){

		int cnt = 1;

		bool chk = true;

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

			if(A[i] % x != 0){

				if(cnt == 1){

					cnt--;

				}else{

					chk = false;

					break;

				}

			}

		}



		if(chk){

			ans = max(ans, x);

		}

	}



	cout << ans << endl;

}


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

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



using namespace std;



typedef long long ll;



ll mygcd(ll a, ll b){

    if(b == 0) return a;

    return mygcd(b, a % b);

}



int main()

{

	cin.tie(0);

	ios::sync_with_stdio(false);



    ll n;

    cin >> n;



    vector<ll> a(n);

    rep(i, n) cin >> a[i];



    vector<ll> lg(n);

    lg[0] = a[0];

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

        lg[i] = mygcd(a[i], lg[i-1]);

    }



    vector<ll> rg(n);

    rg[n-1] = a[n-1];

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

        rg[i] = mygcd(a[i], rg[i+1]);

    }



    ll ans = max(rg[1], lg[n-2]);



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

        ans = max(ans, mygcd(lg[i-1], rg[i+1]));

    }



    cout << ans << endl;

}