stablegradients/pie-gem5-pairs huggingface dataset:
// 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.3854698089175157x):
// GCD on Blackboard - atcoder.cpp : This file contains the 'main' function. Program execution begins and ends there.

//



#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;





int GCD(int x , int y) {

	if (y > x)

		swap(x,y);



	int c = x % y;



	while (c != 0) {

		x = y;

		y = c;

		c = x % y;

	}

	return y;



}

int main()

{

	int n;

	cin >> n; 



	vector <int> elements(n);

	vector<int> prefix(n);

	vector<int> suffix(n);

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

		cin >> elements[i];

	}

	prefix[0] = elements[0];

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

		prefix[i] = GCD(prefix[i - 1], elements[i]);

	}

	suffix[n - 1] = elements[n - 1];

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

		suffix[i] = GCD(suffix[i + 1], elements[i]);

	}



	int m = max(prefix[n-2] ,suffix[1]);

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

		m = max(m,GCD(prefix[i-1] , suffix[i+1]));

	}



	cout << m;

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



using namespace std;

using ii = pair<int, int>;



int eval(int d, const vector<int>& seq) {

    vector<ii> xs;



    for (auto a : seq) {

        auto x = __gcd(d, a);



        if (x < d) {

            xs.push_back(ii(x, a));

        }

    }

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



    for (size_t i = 1; i < xs.size(); i++) {

        d = __gcd(d, xs[i].second);

    }



    return d;

}



int solve(const vector<int>& seq) {

    int N = seq.size();



    //Casos base

    if (N == 1) {

        return seq.front();

    } 

    if (N == 2) {

        return max(seq.front(), seq.back());

    }



    auto d1 = __gcd(seq[0], seq[1]);

    auto ans = eval(d1, seq);



    auto d2 = __gcd(seq[0], seq[2]);

    ans = max(ans, eval(d2, seq));



    auto d3 = __gcd(seq[1], seq[2]);

    ans = max(ans, eval(d3, seq));



    return ans;

}



int main(int argc, char const *argv[])

{

    ios::sync_with_stdio(false);



    int N = 0;

    cin >> N;

    vector<int> seq(N);



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

        int x;

        cin >> x;



        seq[i] = abs(x);

    }



    auto ans = solve(seq);



    cout << ans << endl;



    return 0;

}
// 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.3782690770502863x):
/// إِنَّ مَعَ الْعُسْرِ يُسْرًا

/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ



#include <bits/stdc++.h>

#include <ext/rope>

#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>

#include <ext/pb_ds/assoc_container.hpp>



using namespace __gnu_cxx;

using namespace __gnu_pbds;

using namespace std;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define ll long long

#define ld  double



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

#define S second

#define F first

#define PI acos(-1)

#define MAX 5000005

#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);





int main() {

    HabdModeActive

    int n;

    cin>>n;

    ll arr[n+2];

    ll gcdL[n+2],gcdR[n+2];

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

    {

        cin>>arr[i];

    }

    gcdL[0] = arr[0];

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

    {

        gcdL[i] = __gcd(arr[i],gcdL[i-1]);

    }

    gcdR[n-1] = arr[n-1];

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

    {

        gcdR[i] = __gcd(arr[i],gcdR[i+1]);

    }

    ll mx = 0;

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

    {

        if(i==0)

        {

            mx = max(mx,gcdR[i+1]);

        }

        else if(i==n-1)

        {

            mx = max(mx,gcdL[i-1]);

        }

        else{

            mx = max(mx,__gcd(gcdL[i-1],gcdR[i+1]));

        }

    }

    cout<<mx;



    return 0;

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

using namespace std;



const int N = 1e5 + 5;



int n;

array<int, N> a, front_gcd, back_gcd;



int main() {

    cin >> n;

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

        cin >> a[i];

        if (i == 1) {

            cum_gcd = a[i];

        } else {

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

        }

        front_gcd[i] = cum_gcd;

    }

    

    for (int i = n, cum_gcd = a[n]; i >= 1; i--) {

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

        back_gcd[i] = cum_gcd;

    }

    front_gcd[0] = back_gcd[2];

    back_gcd[n + 1] = front_gcd[n - 1];



    int ans = 0;

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

        ans = max(ans, __gcd(front_gcd[i - 1], back_gcd[i + 1]));

    }



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

using namespace std;

int max(int x,int y)

{

	if(x>y) return x;

	else return y;

}

int gcd (int a,int b){

    while(b){

        int t=a%b;

        a=b;

        b=t;

    }

    return a;

}

int main()

{

	int sum=0;

	int n,a[10005],b[10005],c[100005];

	cin>>n;

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

	{

		cin>>a[i];

	}

	b[0]=a[0];

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

	{

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

	}

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

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

	{

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

	}

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

	{

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

	}

	cout<<max(sum,max(c[1],b[n-2]))<<endl;

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

using namespace std;

const int maxn=2e5+5;

int a[maxn];

int main(){

	int n;

	cin>>n;

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

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

	}

	int ans=-maxn;

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

		int x=0;

		if(a[0]%i!=0) continue;

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

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

			x++;

			if(x==2)

			break;

		}

		if(x<2)

		ans=max(ans,i);

		int ii=a[0]/i;

		x=0;

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

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

			x++;

			if(x==2)

			break;

		}

		if(x<2)

		ans=max(ans,ii);

	}

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

		int x=0;

		if(a[1]%i!=0) continue;

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

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

			x++;

			if(x==2)

			break;

		}

		if(x<2)

		ans=max(ans,i);

		int ii=a[1]/i;

		x=0;

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

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

			x++;

			if(x==2)

			break;

		}

		if(x<2)

		ans=max(ans,ii);

	}

	cout<<ans;

}

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

using namespace std;

const int maxn=2e5+5;

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

int gcd(int a,int b){

	int t;

	if(a<b){

		t=a;

		a=b;

		b=t;

	}

	if(b==0)

	return a;

	for(;;){

		int tmp;

		tmp=b;

		b=a%b;

		a=tmp;

		if(b==0)

		return a;

	}

}

int main(){

	int n;

	cin>>n;

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

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

	}

	

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

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

			}

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

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

		}

			int ans=0;

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

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

				

			}

		

	   //存储下来 不然会TLE 

	cout<<ans;

	return 0;

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

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

#define LEN(x) (int)x.size()

#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)

using namespace std;

typedef int64_t i64;

typedef pair<int,int> pii;

template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}

template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;



void storeDivisor(vector<int> &dst, int n)

{

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

    if (n % i == 0) {

      dst.push_back(i);

      dst.push_back(n / i);

    }

  }

  return;

}



signed main()

{

  int N;

  int a[100010];



  cin >> N;

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



  vector<int> divisors;

  storeDivisor(divisors, a[0]);

  storeDivisor(divisors, a[1]);

  sort(ALL(divisors));

  divisors.erase(unique(ALL(divisors)), divisors.end());





  i64 ans = 1;



  for (int d : divisors) {

    const int cnt = count_if(a, a+N, [d](int a){ return a % d == 0; });

    if (cnt >= N-1) chmax(ans, d);

  }



  cout << ans << endl;



  return 0;

}




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

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

#define LEN(x) (int)x.size()

#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)

using namespace std;

typedef int64_t i64;

typedef pair<int,int> pii;

template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}

template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;



template<class Monoid>

struct SegTree {

  using F = function<Monoid(Monoid, Monoid)>;



  int sz;

  vector<Monoid> u;

  const F f;

  const Monoid M;



  SegTree(int n, const F f, const Monoid &M)

    : f(f), M(M)

  {

    for (sz = 1; sz < n; sz <<= 1);

    u.assign(sz * 2, M);

  }



  void set(int i, const Monoid &v) {

    u[i + sz] = v;

  }



  void build() {

    for (int i = sz-1; i > 0; --i) u[i] = calc(i);

  }



  void update(int i, const Monoid &v) {

    u[i += sz] = v;

    while(i >>= 1) u[i] = calc(i);

  }



  Monoid query(int a, int b) const {

    Monoid L = M, R = M;

    for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {

      if (a & 1) L = f(L, u[a++]);

      if (b & 1) R = f(u[--b], R);

    }

    return f(L, R);

  }



  Monoid calc(int i) const {

    return f(u[2 * i + 0], u[2 * i + 1]);

  }



  const Monoid& operator[] (int i) const {

    return u[i + sz];

  }

};



signed main()

{

  int N; cin >> N;



  SegTree<int> seg(

      N+1,

      [](int a, int b) { return __gcd(a,b); },

      0);



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

    int a; cin >> a;

    seg.set(i, a);

  }



  seg.build();



  int ans = 1;

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

    chmax(ans, __gcd(seg.query(0, i), seg.query(i+1, N+1)));

  }



  cout << ans << endl;



  return 0;

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

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

#define LEN(x) (int)x.size()

#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)

using namespace std;

typedef int64_t i64;

typedef pair<int,int> pii;

template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}

template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;



void storeDivisor(vector<int> &dst, int n)

{

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

    if (n % i == 0) {

      dst.push_back(i);

      dst.push_back(n / i);

    }

  }

  return;

}



signed main()

{

  int N;

  int a[100010];



  cin >> N;

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



  vector<int> divisors;

  storeDivisor(divisors, a[0]);

  storeDivisor(divisors, a[1]);

  sort(ALL(divisors));

  divisors.erase(unique(ALL(divisors)), divisors.end());





  i64 ans = 1;



  for (int d : divisors) {

    const int cnt = count_if(a, a+N, [d](int a){ return a % d == 0; });

    if (cnt >= N-1) chmax(ans, d);

  }



  cout << ans << endl;



  return 0;

}




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

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

#define LEN(x) (int)x.size()

#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)

using namespace std;

typedef int64_t i64;

typedef pair<int,int> pii;

template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}

template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;



constexpr const int N_MAX = 100010;

constexpr const int sqrtN = 512;



int N, K;

int a[N_MAX];

int b[N_MAX / sqrtN + 1];



void build()

{

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

    b[i / sqrtN] = __gcd(b[i / sqrtN], a[i]);

  }

}



int query(int l, int r)

{

  int ret = 0;

  while(l < r && l % sqrtN != 0) ret = __gcd(ret, a[l++]);

  while(l < r && r % sqrtN != 0) ret = __gcd(a[--r], ret);



  for (int i = l/sqrtN; i < r/sqrtN; ++i) {

    ret = __gcd(ret, b[i]);

  }



  return ret;

}



signed main()

{

  iostreamBooster();



  cin >> N;

  K = (N + sqrtN - 1) / sqrtN;



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

    cin >> a[i];

  }



  build();



  int maxv = 0;

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

    chmax(

        maxv,

        __gcd(query(1, i), query(i+1, N+1))

    );

  }



  cout << maxv << endl;





  return 0;

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

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

#define LEN(x) (int)x.size()

#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)

using namespace std;

typedef int64_t i64;

typedef pair<int,int> pii;

template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}

template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;



void storeDivisor(vector<int> &dst, int n)

{

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

    if (n % i == 0) {

      dst.push_back(i);

      dst.push_back(n / i);

    }

  }

  return;

}



signed main()

{

  int N;

  int a[100010];



  cin >> N;

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



  vector<int> divisors;

  storeDivisor(divisors, a[0]);

  storeDivisor(divisors, a[1]);

  sort(ALL(divisors));

  divisors.erase(unique(ALL(divisors)), divisors.end());





  i64 ans = 1;



  for (int d : divisors) {

    const int cnt = count_if(a, a+N, [d](int a){ return a % d == 0; });

    if (cnt >= N-1) chmax(ans, d);

  }



  cout << ans << endl;



  return 0;

}




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

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

#define LEN(x) (int)x.size()

#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)

using namespace std;

typedef int64_t i64;

typedef pair<int,int> pii;

template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}

template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;



constexpr const int N_MAX = 100010;

constexpr const int sqrtN = 300;



int N, K;

int a[N_MAX];

int b[N_MAX / sqrtN + 1];



void build()

{

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

    b[i / sqrtN] = __gcd(b[i / sqrtN], a[i]);

  }

}



int query(int l, int r)

{

  int ret = 0;

  while(l < r && l % sqrtN != 0) ret = __gcd(ret, a[l++]);

  while(l < r && r % sqrtN != 0) ret = __gcd(a[--r], ret);



  for (int i = l/sqrtN; i < r/sqrtN; ++i) {

    ret = __gcd(ret, b[i]);

  }



  return ret;

}



signed main()

{

  iostreamBooster();



  cin >> N;

  K = (N + sqrtN - 1) / sqrtN;



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

    cin >> a[i];

  }



  build();



  int maxv = 0;

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

    chmax(

        maxv,

        __gcd(query(1, i), query(i+1, N+1))

    );

  }



  cout << maxv << endl;





  return 0;

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

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

#define LEN(x) (int)x.size()

#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)

using namespace std;

typedef int64_t i64;

typedef pair<int,int> pii;

template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}

template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;



void storeDivisor(vector<int> &dst, int n)

{

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

    if (n % i == 0) {

      dst.push_back(i);

      dst.push_back(n / i);

    }

  }

  return;

}



signed main()

{

  int N;

  int a[100010];



  cin >> N;

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



  vector<int> divisors;

  storeDivisor(divisors, a[0]);

  storeDivisor(divisors, a[1]);

  sort(ALL(divisors));

  divisors.erase(unique(ALL(divisors)), divisors.end());





  i64 ans = 1;



  for (int d : divisors) {

    const int cnt = count_if(a, a+N, [d](int a){ return a % d == 0; });

    if (cnt >= N-1) chmax(ans, d);

  }



  cout << ans << endl;



  return 0;

}




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

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

#define LEN(x) (int)x.size()

#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)

using namespace std;

typedef int64_t i64;

typedef pair<int,int> pii;

template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}

template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;



constexpr const int N_MAX = 100010;

constexpr const int sqrtN = 200;



int N, K;

int a[N_MAX];

int b[N_MAX / sqrtN + 1];



void build()

{

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

    b[i / sqrtN] = __gcd(b[i / sqrtN], a[i]);

  }

}



int query(int l, int r)

{

  int ret = 0;

  while(l < r && l % sqrtN != 0) ret = __gcd(ret, a[l++]);

  while(l < r && r % sqrtN != 0) ret = __gcd(a[--r], ret);



  for (int i = l/sqrtN; i < r/sqrtN; ++i) {

    ret = __gcd(ret, b[i]);

  }



  return ret;

}



signed main()

{

  iostreamBooster();



  cin >> N;

  K = (N + sqrtN - 1) / sqrtN;



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

    cin >> a[i];

  }



  build();



  int maxv = 0;

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

    chmax(

        maxv,

        __gcd(query(1, i), query(i+1, N+1))

    );

  }



  cout << maxv << endl;





  return 0;

}