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

#include <climits>

#include <cmath>

#include <complex>

#include <cstdio>

#include <iostream>

#include <numeric>

#include <vector>

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



typedef long long ll;

typedef unsigned long long ull;



using namespace std;



template <typename T>

vector<size_t> sort_indexes(const vector<T> &v) {

  vector<size_t> idx(v.size());

  iota(idx.begin(), idx.end(), 0);

  sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { return v[i1] < v[i2]; });

  return idx;

}



ll gcd(ll a,ll b) {

  ll gmax = 1;

  ll aa = (a<b)?a:b;

  ll bb = (a<b)?b:a;

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

    if (aa%i==0) {

      if (bb%(aa/i) == 0) {

        gmax = aa/i;

        break;

      }

      if (bb%i == 0) {

        gmax = i;

      }

    }

  }

  return gmax;

}



int main() {

  ll n;

  cin >> n;

  ll a[n];

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

  ll gcd_max = 1;

  ll gcd_arr[n];

  ll gcd_arr2[n];

  ll cgcd;

  gcd_arr[0] = a[0];

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

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

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

  _for(i, n) {

    if (i == 0)

      cgcd = gcd_arr2[1];

    else if (i == n - 1)

      cgcd = gcd_arr[n - 2];

    else

      cgcd = gcd(gcd_arr[i - 1], gcd_arr2[i + 1]);

    gcd_max = max(gcd_max, cgcd);

  }

  cout << gcd_max << endl;

  return 0;

}

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

#include <climits>

#include <cmath>

#include <complex>

#include <cstdio>

#include <iostream>

#include <numeric>

#include <vector>

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



typedef long long ll;

typedef unsigned long long ull;



using namespace std;



template <typename T>

vector<size_t> sort_indexes(const vector<T> &v) {

  vector<size_t> idx(v.size());

  iota(idx.begin(), idx.end(), 0);

  sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { return v[i1] < v[i2]; });

  return idx;

}



// ll gcd(ll a,ll b) {

//   ll gmax = 1;

//   ll aa = (a<b)?a:b;

//   ll bb = (a<b)?b:a;

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

//     if (aa%i==0) {

//       if (bb%(aa/i) == 0) {

//         gmax = aa/i;

//         break;

//       }

//       if (bb%i == 0) {

//         gmax = i;

//       }

//     }

//   }

//   return gmax;

// }



ll gcd(ll a,ll b) {

  if (b==0) return a;

  return gcd(b,a%b);

}



int main() {

  ll n;

  cin >> n;

  ll a[n];

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

  ll gcd_max = 1;

  ll gcd_arr[n];

  ll gcd_arr2[n];

  ll cgcd;

  gcd_arr[0] = a[0];

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

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

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

  _for(i, n) {

    if (i == 0)

      cgcd = gcd_arr2[1];

    else if (i == n - 1)

      cgcd = gcd_arr[n - 2];

    else

      cgcd = gcd(gcd_arr[i - 1], gcd_arr2[i + 1]);

    gcd_max = max(gcd_max, cgcd);

  }

  cout << gcd_max << endl;

  return 0;

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

using namespace std;



int n, g, ans=0;

vector<int> a(500000);

vector<int> l(500000);

vector<int> r(500000);





int gcd(int a, int b) {

    if (a < b) return gcd(b, a);

    while(b!=0){

        int r = a%b;

        a = b;

        b = r;

    }

    return a; 

}





int main() {

    cin >> n;

    for (int i = 0; i < n; ++i) cin >> a.at(i);



    l.at(0) = 0; 

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

    {

        l.at(i) = gcd(l.at(i-1), a.at(i-1));

    }



    r.at(n) = 0; 

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

    {

        r.at(i) = gcd(r.at(i+1), a.at(i));

    }



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

    {

        ans = max(gcd(l.at(i), r.at(i+1)), ans);

    }

    

    cout << ans << endl;

}

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

using namespace std;



int n, g, ans=0;

vector<int> a(500000);



int gcd(int a, int b) {

    if (a < b) return gcd(b, a);

    while(b!=0){

        int r = a%b;

        a = b;

        b = r;

    }

    return a; 

}



int main() {

    cin >> n;

    for (int i = 0; i < n; ++i) cin >> a.at(i);



    vector<int> l(n+1, 0);

    vector<int> r(n+1, 0);



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

        l.at(i+1) = gcd(l.at(i), a.at(i));



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

        r.at(i) = gcd(r.at(i+1), a.at(i));



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

        ans = max(gcd(l.at(i), r.at(i+1)), ans);

    

    cout << ans << endl;

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

using namespace std;



#define int long long

#define pb push_back

#define f first

#define s second

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



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



int32_t main(){



    fast;

    int n; cin >> n;

    int ar[n];



    int maxx_freq = -1 , element = -1;

    map<int,int> mp;



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

      cin >> ar[i];

      mp[ar[i]]++;

      if(mp[ar[i]]>maxx_freq){

        maxx_freq = mp[ar[i]];

        element = ar[i];

      }

    } 

    

    if(maxx_freq==1){

      for(auto p : mp) element = max(element,p.f);

    }

    // cout << "maxx " << element << '\n';



    vector<int> divisor;



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

      if(element%i==0){

        divisor.pb(i);

        if(i!=element/i) divisor.pb(element/i);

      }

    }



    int ans = -1;



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

      int gcd = 0;

      bool flag = false;

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

        if(ar[j]%divisor[i]!=0&&!flag){

          gcd = __gcd(divisor[i],gcd);

          flag = true;

        }

        else {

          gcd = __gcd(ar[j],gcd);

        }

      }

      ans = max(ans,gcd);

    }



    cout << ans << '\n';





    return 0;

} 

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

using namespace std;



#define int long long

#define pb push_back

#define f first

#define s second

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



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



int32_t main(){

  

    fast;

    int n; cin >> n;

    int ar[n+1];



    for(int i=1;i<=n;i++) cin >> ar[i];



    int leftgcd[n+1] = {0};

    int rightgcd[n+2] = {0};



    leftgcd[0] = 0;

    rightgcd[n+1] = 0;



    for(int i=1;i<=n;i++) leftgcd[i] = __gcd(ar[i],leftgcd[i-1]);



    for(int i=n;i>=1;i--) rightgcd[i] = __gcd(ar[i],rightgcd[i+1]);

    

    int maxx = -1;

    

    for(int i=1;i<=n;i++) maxx = max(maxx,__gcd(leftgcd[i-1],rightgcd[i+1]));



    cout << maxx;

    

    return 0;

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

#include <vector>

#include <algorithm>



using namespace std;



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

{

	std::vector<int> ret;

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

	{

		if(n%i == 0)

		{

			ret.push_back(i);

			if(i*i!=n)

			{

				ret.push_back(n/i);

			}

		}

	}

    sort(ret.begin(), ret.end(), greater<int>());

	return ret;

}



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 result0 = A[0];

    vector <int> EA0 = enum_div(A[0]);

    int j = 0;



    while(result0 > 0){

        int count = 0;

        result0 = EA0[j];

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

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

                count += 1;

            }

        }

        if (count <= 1) {

            break;

        }else{

            j += 1;

        }

    }



    int result1 = A[1];

    vector <int> EA = enum_div(A[1]);

    j = 0;

    while(result1 > 0){

        int count = 0;

        result1 = EA[j];

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

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

                count += 1;

            }

        }

        if (count <= 1) {

            break;

        }else{

            j += 1;

        }

    }



    if (result0 >= result1) {

        cout << result0 << endl;

    }else{

        cout << result1 << endl;

    }

    

    

    



    return 0;

}

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

#include <vector>

#include <string>

#include <cmath>

#include <algorithm>

#include <map>

#include <iomanip>

#include <stdlib.h>

#include <queue>



using namespace std;



const int nmax = 1e9 + 7;

typedef long long ll;



int GCD(int a, int b){

  int M = max(a, b), m = min(a, b);

  if (m == 0){

    return M;

  }else{

    while (M % m != 0){

      int res = M % m;

      M = m; m = res;

    }

    return m;

  }

}



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



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

  L[0] = 0; L[1] = A[0];

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

    L[i] = GCD(A[i - 1], L[i - 1]);

  }

  

  R[N - 1] = 0; R[N - 2] = A[N - 1];

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

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

  }

  

  int ans = 0;

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

    if (ans < GCD(L[i], R[i])){

      ans = GCD(L[i], R[i]);

    }

  }

  cout << ans << endl;

  

  return 0;

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

#include <vector>

#include <algorithm>



using namespace std;



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

{

	std::vector<int> ret;

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

	{

		if(n%i == 0)

		{

			ret.push_back(i);

			if(i*i!=n)

			{

				ret.push_back(n/i);

			}

		}

	}

    sort(ret.begin(), ret.end(), greater<int>());

	return ret;

}



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 result0 = A[0];

    vector <int> EA0 = enum_div(A[0]);

    int j = 0;



    while(result0 > 0){

        int count = 0;

        result0 = EA0[j];

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

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

                count += 1;

            }

        }

        if (count <= 1) {

            break;

        }else{

            j += 1;

        }

    }



    int result1 = A[1];

    vector <int> EA = enum_div(A[1]);

    j = 0;

    while(result1 > 0){

        int count = 0;

        result1 = EA[j];

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

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

                count += 1;

            }

        }

        if (count <= 1) {

            break;

        }else{

            j += 1;

        }

    }



    if (result0 >= result1) {

        cout << result0 << endl;

    }else{

        cout << result1 << endl;

    }

    

    

    



    return 0;

}

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



using namespace std;

 

typedef long long ll;

typedef long double ld;

typedef pair<int, int> Pii;

typedef pair<int, ll> Pil;

typedef pair<ll, ll> Pll;

typedef pair<ll, int> Pli;



#define fi first

#define se second



const ll MOD = 1e9 + 7;

const ll MOD2 = 998244353;

const ll MOD3 = 1812447359;

const ll INF = 1ll << 62;

const double PI = 2 * asin(1);



void yes() {printf("yes\n");}

void no() {printf("no\n");}

void Yes() {printf("Yes\n");}

void No() {printf("No\n");}

void YES() {printf("YES\n");}

void NO() {printf("NO\n");}



ll GCD(ll A, ll B){

  if (A < B) swap(A, B);

  while (A % B != 0){

    A %= B; swap(A, B);

  }

  return B;

}



int N;

ll A[int(1e5+5)];

ll L[int(1e5+5)], R[int(1e5+5)];



int main(){

  cin >> N;

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



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

  }



  ll ans = max(R[1], L[N - 2]);



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

    ans = max(ans, GCD(L[i-1], R[i+1]));

  }

  cout << ans << endl;



  return 0;

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

#include <vector>

#include <algorithm>

#include <map>

#include <set>

#include <cmath>

#include <cstring>

#include <iomanip>

#include <random>

#include <chrono>

#include <queue>

#include <ctime>

using namespace std;

typedef long long ll;

typedef pair<int, int> PII;

typedef pair<ll, ll> PLL;

#define fs first

#define sc second

#define INF 1000000000

#define MOD 1000000007

#define EPS 0.00000001



int main() {

    int N; cin >> N;

    vector<int> A(N);

    for(int &a:A)

        cin >> a;



    set<int> S;

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

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

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

                S.insert(j);

                S.insert(A[i]/j);

            }

        }

    }

    

    map<int, int> M;

    for(int s:S){

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

            if(A[j]%s==0) M[s]++;

        }

    }

    

    int ans = 0;

    for(auto m:M){

        if(m.sc >= N-1) ans = max(ans, m.fs);

    }

        

    cout << ans << endl;

    return 0;

}


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

#include <vector>

#include <algorithm>

#include <map>

#include <set>

#include <cmath>

#include <cstring>

#include <iomanip>

#include <random>

#include <chrono>

#include <queue>

#include <ctime>

using namespace std;

typedef long long ll;

typedef pair<int, int> PII;

typedef pair<ll, ll> PLL;

#define fs first

#define sc second

#define INF 1000000000

#define MOD 1000000007

#define EPS 0.00000001





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 &a:A)

        cin >> a;

    vector<vector<int>> dp(N+1, vector<int>(3));

    

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

        dp[i+1][0] = gcd(dp[i][0], A[i]);

        dp[i+1][1] = dp[i][0];

        dp[i+1][2] = max(gcd(dp[i][1], A[i]), gcd(dp[i][2], A[i]));

    }

    cout << max(dp[N][1], dp[N][2]) << endl;

    return 0;

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

using namespace std;

using ll = long long;

#define fi first

#define se second

vector<ll> finddivisor(ll x){//整数xの約数が入ったvectorを返すよ(xを含む)  

    vector<ll> divisor;

    for(ll i=1; (i*i)<=x ;i++)

    {

        if(x%i==0){

            divisor.push_back(i);

            if(i*i!=x){

                divisor.push_back(x/i);

            }//約数はペアを持つことを利用



        }

    }

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

    //divisor.push_back(x);

    return divisor;

}

int main(){

    ll n,ans=1;

    cin >> n;

    vector<ll> v(n),a,b;

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

    {

        cin >> v.at(i);

    }

    a=finddivisor(v.at(0));

    b=finddivisor(v.at(1));



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

    {

        ll cnt=0;

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

        {

            if(v.at(j)%a.at(i)!=0){

                cnt++;

            }

            if(cnt>=2){

                break;

            }

        }

        if(cnt<2){

            ans=max(ans,a.at(i));

        }

    }

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

    {

        ll cnt=0;

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

        {

            if(v.at(j)%b.at(i)!=0){

                cnt++;

            }

            if(cnt>=2){

                break;

            }

        }

        if(cnt<2){

            ans=max(ans,b.at(i));

        }

    }

    cout << ans << endl;

}

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

using namespace std;

using ll = long long;

#define fi first

#define se second



ll gcd(ll a,ll b){//最大公約数を求める関数

    if(a<b){

        swap(a,b);

    }



    if(a%b == 0){

        return b;

    }else{

    return gcd(b,a%b);

    }

}

/*問題文を言い換えると、A1からANのうち一つの数を除いた時の、

A1からAN(全部でN-1個）の最大公約数の最大値を求める

とりあえず一つずつ除いてみて、最大公約数を求め、最大値を出力すればよい



同じ部分のgcdを何度も計算したくない→累積gcd(先に計算しておいて後で利用）

同じ処理を何度もしたくない時は先に計算しておいて後で参照できるようにしておく*/



int main(){

    ll n,ans=0;

    cin >> n;

    vector<ll> v(n),g(n,0),c(n,0);//gは左からの,cは右からの累積テーブル

    for(int i=0;i < n;i++)//入力

    {

        cin >> v.at(i);

    }



    g.at(1)=v.at(0);

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

    {

        g.at(i)=gcd(g.at(i-1),v.at(i-1));

    }//g.at(i)はv.at(0)からv.at(i-1)のgcd



    c.at(n-2)=v.at(n-1);

    for(int i=n-3;0<=i;i--)

    {

        c.at(i)=gcd(c.at(i+1),v.at(i+1));

    }//c.at(i)はv.at(i+1)からv.at(n)のgcd



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

    {

        ans=max(ans,gcd(g.at(i),c.at(i)));

        //gcd(g.at(i),c.at(i)) はv.at(i)を除いたときの最大公約数

        //g.at(i)はv.at(0)からv.at(i-1)の最大公約数、同様に

        //c.at(i)はv.at(i+1)からv.at(n-1)の最大公約数

        //v.at(0)とv.at(n-1)を除くときは下で別の処理をしてる（それぞれ左側,右側のgcdがないので)

    }

    ans=max(ans,g.at(n-1));

    ans=max(ans,c.at(0));

    cout << ans << 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.3762950388619135x):
#include <iostream>

#include <algorithm>



using namespace std;

int maxi,n,i,a[100005];

int dps[100005],dpd[100005];

int main()

{

    cin>>n;

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

        cin>>a[i];

    dps[2]=a[1];

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



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

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



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

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



    maxi=max(dpd[1], dps[n]);



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

        maxi=max(maxi, __gcd(dps[i], dpd[i]));



    cout<<maxi;

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

#include <algorithm>



using namespace std;

int maxi,n,i,a[100005];

int dps[100005],dpd[100005];

int main()

{

    cin>>n;

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

        cin>>a[i];

    dps[2]=a[1];

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



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

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



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

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



    maxi=max(dpd[1], dps[n]);



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

        maxi=max(maxi, __gcd(dps[i], dpd[i]));



    cout<<maxi;

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



using namespace std;



typedef long long ll;



vector<bool> valid;

vector<ll> nums;

vector<ll> nums1;

vector<ll> nums2;



int main(){

	ll n;

	ll max = 1;

	cin >> n;



	nums.resize(n);

	nums1.resize(n,0);

	nums2.resize(n,0);

	for(ll i=0; i<n; i++) cin >> nums[i];

	

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

		nums1[i+1] = __gcd(nums1[i],nums[i]);

	}

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

		nums2[i-1] = __gcd(nums2[i],nums[i]);

	}



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

		if(max<__gcd(nums1[i],nums2[i])) max = __gcd(nums1[i],nums2[i]);

	}



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



using namespace std;



typedef long long ll;



vector<bool> valid;

vector<ll> nums;

vector<ll> nums1;

vector<ll> nums2;



int main(){

	ll n;

	ll max = 1;

	cin >> n;



	nums.resize(n);

	nums1.resize(n,0);

	nums2.resize(n,0);

	for(ll i=0; i<n; i++) cin >> nums[i];

	

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

		nums1[i+1] = __gcd(nums1[i],nums[i]);

	}

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

		nums2[i-1] = __gcd(nums2[i],nums[i]);

	}



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

		if(max<__gcd(nums1[i],nums2[i])) max = __gcd(nums1[i],nums2[i]);

	}



	cout << max << endl;



	return 0;

}