stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



#define PROBLEM "C"

#define TESTC ""



#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)

typedef pair<int, int> P;

#define F first

#define S second

#define INF 0x3f3f3f3f

#define MP make_pair

#define PB push_back

#define MAXN 100005

#define LL long long



LL l[MAXN];

LL r[MAXN];

LL dp[MAXN];



int main()

{

	#ifdef DBG

	freopen(PROBLEM TESTC ".in", "r", stdin);

	freopen(PROBLEM ".out", "w", stdout);

	#endif



	int n;

	while(~scanf("%d",&n))

	{

		int tmp;

		memset(dp, 0, sizeof(dp));

		memset(r,0,sizeof(r));

		memset(l,0,sizeof(l));

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

		{

			scanf("%d",&tmp);

			dp[i] = tmp;

		}

		//算前綴

		l[0] = dp[0];

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

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

		

		//算後綴

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

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

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



		LL ans = 1;

		//嘗試砍每一個

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

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

		

		//砍頭砍尾

		ans = max(ans, max(r[1],l[n-2]));





		cout << ans << '\n';



		

	}

	

	



	return 0;

}

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

#include <vector>

#include <algorithm>

#include <math.h>

 

using namespace std;

typedef long long ll;

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

 

ll gcd(ll n1, ll n2)

{

    return n2 == 0 ? n1 : gcd(n2, n1 % n2);

}

 

int main(){

    ll N, ans = 0;

    cin >> N;

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

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

    L[1] = A[0], R[N - 1] = A[N - 1];

 

    rep(0,N-1){

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

        R[N - 2 - i] = gcd(R[N - i - 1], A[N - 2 - i]);

    }

    L[0] = R[N-1],R[N] = L[1];

    rep(0,N){

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

    }

    cout << ans << endl;

    return 0;

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



using namespace std;



#define PROBLEM "C"

#define TESTC ""



#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)

typedef pair<int, int> P;

#define F first

#define S second

#define INF 0x3f3f3f3f

#define MP make_pair

#define PB push_back

#define MAXN 100005

#define LL long long



LL l[MAXN];

LL r[MAXN];

LL dp[MAXN];



int main()

{

	#ifdef DBG

	freopen(PROBLEM TESTC ".in", "r", stdin);

	freopen(PROBLEM ".out", "w", stdout);

	#endif



	int n;

	while(~scanf("%d",&n))

	{

		int tmp;

		memset(dp, 0, sizeof(dp));

		memset(r,0,sizeof(r));

		memset(l,0,sizeof(l));

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

		{

			scanf("%d",&tmp);

			dp[i] = tmp;

		}

		//算前綴

		l[0] = dp[0];

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

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

		

		//算後綴

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

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

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



		LL ans = 1;

		//嘗試砍每一個

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

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

		

		//砍頭砍尾

		ans = max(ans, max(r[1],l[n-2]));





		cout << ans << '\n';



		

	}

	

	



	return 0;

}

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

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

#define MAX_V 200005



using namespace std;



int p[MAX_V], s[MAX_V], v[MAX_V];



int main()

{

    FAST_IO;

    int n;

    scanf("%d", &n);

    scanf("%d", v+0);

    p[0] = v[0];

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

        scanf("%d", v+i);

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

    }

    s[n-1] = v[n-1];

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

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



    int ans = max(s[1], p[n-2]);

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

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



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

    return 0;

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



using namespace std;



#define PROBLEM "C"

#define TESTC ""



#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)

typedef pair<int, int> P;

#define F first

#define S second

#define INF 0x3f3f3f3f

#define MP make_pair

#define PB push_back

#define MAXN 100005

#define LL long long



LL l[MAXN];

LL r[MAXN];

LL dp[MAXN];



int main()

{

	#ifdef DBG

	freopen(PROBLEM TESTC ".in", "r", stdin);

	freopen(PROBLEM ".out", "w", stdout);

	#endif



	int n;

	while(~scanf("%d",&n))

	{

		int tmp;

		memset(dp, 0, sizeof(dp));

		memset(r,0,sizeof(r));

		memset(l,0,sizeof(l));

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

		{

			scanf("%d",&tmp);

			dp[i] = tmp;

		}

		//算前綴

		l[0] = dp[0];

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

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

		

		//算後綴

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

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

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



		LL ans = 1;

		//嘗試砍每一個

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

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

		

		//砍頭砍尾

		ans = max(ans, max(r[1],l[n-2]));





		cout << ans << '\n';



		

	}

	

	



	return 0;

}

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

    ios::sync_with_stdio(false);



    int n; cin >> n; 

    int a[100010];



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

    // cout << gcd(5, 3);

    // return 0; 

    

    // prefix 

    int prefix[100010];

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

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

    }

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

    //     cout << prefix[i] << "  ";

    // }

    // suffix

    int suffix[100010];

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

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

    }

    // cout << endl; 

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

    // //     cout << suffix[i] << "  ";

    // // }



    int best = 1; 

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

        int val = gcd(prefix[i-1], suffix[i+1]);

        if  (val > best) best = val; 

    }



    cout << best << endl; 



    

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



using namespace std;



#define PROBLEM "C"

#define TESTC ""



#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)

typedef pair<int, int> P;

#define F first

#define S second

#define INF 0x3f3f3f3f

#define MP make_pair

#define PB push_back

#define MAXN 100005

#define LL long long



LL l[MAXN];

LL r[MAXN];

LL dp[MAXN];



int main()

{

	#ifdef DBG

	freopen(PROBLEM TESTC ".in", "r", stdin);

	freopen(PROBLEM ".out", "w", stdout);

	#endif



	int n;

	while(~scanf("%d",&n))

	{

		int tmp;

		memset(dp, 0, sizeof(dp));

		memset(r,0,sizeof(r));

		memset(l,0,sizeof(l));

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

		{

			scanf("%d",&tmp);

			dp[i] = tmp;

		}

		//算前綴

		l[0] = dp[0];

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

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

		

		//算後綴

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

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

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



		LL ans = 1;

		//嘗試砍每一個

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

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

		

		//砍頭砍尾

		ans = max(ans, max(r[1],l[n-2]));





		cout << ans << '\n';



		

	}

	

	



	return 0;

}

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



using namespace std;

#define  ll long long

#define ld long double

#define f first

#define s second

const int N = 2e5+5;



ll pre[N] , suf[N] , n , a[N] , ans=0;





int main()

{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);



    cin >> n;

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

    {

        cin >> a[i];

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

    }



    ans = pre[n];

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

    {

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

    }



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

    {

        ll tmp = __gcd(suf[i+1] , pre[i-1]);

        ans = max(ans , tmp);

    }

    cout << ans << '\n';



    return 0;

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



using namespace std;



#define PROBLEM "C"

#define TESTC ""



#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)

typedef pair<int, int> P;

#define F first

#define S second

#define INF 0x3f3f3f3f

#define MP make_pair

#define PB push_back

#define MAXN 100005

#define LL long long



LL l[MAXN];

LL r[MAXN];

LL dp[MAXN];



int main()

{

	#ifdef DBG

	freopen(PROBLEM TESTC ".in", "r", stdin);

	freopen(PROBLEM ".out", "w", stdout);

	#endif



	int n;

	while(~scanf("%d",&n))

	{

		int tmp;

		memset(dp, 0, sizeof(dp));

		memset(r,0,sizeof(r));

		memset(l,0,sizeof(l));

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

		{

			scanf("%d",&tmp);

			dp[i] = tmp;

		}

		//算前綴

		l[0] = dp[0];

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

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

		

		//算後綴

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

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

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



		LL ans = 1;

		//嘗試砍每一個

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

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

		

		//砍頭砍尾

		ans = max(ans, max(r[1],l[n-2]));





		cout << ans << '\n';



		

	}

	

	



	return 0;

}

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



using namespace std;



typedef long long ll;

typedef long double ld;



const int N = 1e5 + 5;

int pre[N], suf[N], arr[N];



int main() {

	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

#ifdef ONLINE_JUDGE

    // freopen("", "r", stdin);

    // freopen("", "w", stdout);

#endif

	int n;

	cin >> n;

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



		cin >> arr[i];

		pre[i] = arr[i];

		if(i)

			pre[i] = __gcd(pre[i], pre[i - 1]);

	}

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

		suf[i] = arr[i];

		if(i != n - 1)

			suf[i] = __gcd(suf[i], suf[i + 1]);

	}

	int ans = 0;

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

		if(i == 0){

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

		}

		else if(i == n - 1){

			ans = max(ans, pre[i - 1]);

		}

		else

			ans = max(ans, __gcd(pre[i - 1], suf[i + 1]));

	}

	cout << ans;

	return 0;

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



using namespace std;



#define PROBLEM "C"

#define TESTC ""



#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)

typedef pair<int, int> P;

#define F first

#define S second

#define INF 0x3f3f3f3f

#define MP make_pair

#define PB push_back

#define MAXN 100005

#define LL long long



LL l[MAXN];

LL r[MAXN];

LL dp[MAXN];



int main()

{

	#ifdef DBG

	freopen(PROBLEM TESTC ".in", "r", stdin);

	freopen(PROBLEM ".out", "w", stdout);

	#endif



	int n;

	while(~scanf("%d",&n))

	{

		int tmp;

		memset(dp, 0, sizeof(dp));

		memset(r,0,sizeof(r));

		memset(l,0,sizeof(l));

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

		{

			scanf("%d",&tmp);

			dp[i] = tmp;

		}

		//算前綴

		l[0] = dp[0];

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

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

		

		//算後綴

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

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

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



		LL ans = 1;

		//嘗試砍每一個

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

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

		

		//砍頭砍尾

		ans = max(ans, max(r[1],l[n-2]));





		cout << ans << '\n';



		

	}

	

	



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.3593750483229345x):
//#pragma GCC optimize ('O3')

#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<ll,ll> pll;

typedef long double ld;

#define mp make_pair

#define f first

#define s second

#define pb push_back



const int N = 1e5 + 5;

const int M = 1e5 + 5;

const ll OO = 1e18;

const int mod = 1e9 + 7;



int n,a[N],ans=1,tree[1<<20];



void build(int idx = 0, int st = 0, int en = n-1) {



    if(st==en) return tree[idx] = a[st], void();



    int mid = st + (en-st)/2, lf = 2*idx + 1, rt = lf + 1;

    build(lf,st,mid);

    build(rt,mid+1,en);

    tree[idx] = __gcd(tree[lf],tree[rt]);



}



int query(int a = 0, int b = n-1, int idx = 0, int st = 0, int en = n-1) {



    if(a>b) return 0;

    if(a>en || st>b) return 0;

    if(a<=st && en<=b) return tree[idx];

    int mid = st + (en-st)/2, lf = 2*idx + 1, rt = lf + 1;

    return __gcd(query(a,b,lf,st,mid),query(a,b,rt,mid+1,en));



}



int main() {



    ios_base::sync_with_stdio(false);

    cin.tie(0);



    cin >> n;



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

        cin >> a[i];

    }



    build();



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

        ans = max(ans, __gcd(query(0,i-1),query(i+1,n-1)));

    }



    cout << ans << '\n';



    return 0;

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



using namespace std;



#define PROBLEM "C"

#define TESTC ""



#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)

typedef pair<int, int> P;

#define F first

#define S second

#define INF 0x3f3f3f3f

#define MP make_pair

#define PB push_back

#define MAXN 100005

#define LL long long



LL l[MAXN];

LL r[MAXN];

LL dp[MAXN];



int main()

{

	#ifdef DBG

	freopen(PROBLEM TESTC ".in", "r", stdin);

	freopen(PROBLEM ".out", "w", stdout);

	#endif



	int n;

	while(~scanf("%d",&n))

	{

		int tmp;

		memset(dp, 0, sizeof(dp));

		memset(r,0,sizeof(r));

		memset(l,0,sizeof(l));

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

		{

			scanf("%d",&tmp);

			dp[i] = tmp;

		}

		//算前綴

		l[0] = dp[0];

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

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

		

		//算後綴

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

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

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



		LL ans = 1;

		//嘗試砍每一個

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

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

		

		//砍頭砍尾

		ans = max(ans, max(r[1],l[n-2]));





		cout << ans << '\n';



		

	}

	

	



	return 0;

}

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

#define fio     ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);

#define pi      3.14159265

#define ll      long long

#define repe    ll tc,cas=0;cin>>tc;while(tc--)

#define op      freopen("output.txt", "w", stdout);



#define maxn 10000010

using namespace std;





int main()

{

    fio;



    int n;cin>>n;



    int arr[n+1],frnt[n+1],bak[n+1];

    int gc=0;

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

        cin>>arr[i];

        frnt[i]=__gcd(arr[i],gc);

        gc=frnt[i];

    }

    gc=0;

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

    {

        bak[i]=__gcd(arr[i],gc);

        gc=bak[i];

    }

    int mx=-1;

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

        if(i==0)gc = bak[1];

        else if(i==n-1) gc = frnt[n-2];

        else gc = __gcd(frnt[i-1],bak[i+1]);

        mx = max(mx,gc);

    }



    cout<<mx<<endl;

    return 0;

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



using namespace std;



#define PROBLEM "C"

#define TESTC ""



#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)

typedef pair<int, int> P;

#define F first

#define S second

#define INF 0x3f3f3f3f

#define MP make_pair

#define PB push_back

#define MAXN 100005

#define LL long long



LL l[MAXN];

LL r[MAXN];

LL dp[MAXN];



int main()

{

	#ifdef DBG

	freopen(PROBLEM TESTC ".in", "r", stdin);

	freopen(PROBLEM ".out", "w", stdout);

	#endif



	int n;

	while(~scanf("%d",&n))

	{

		int tmp;

		memset(dp, 0, sizeof(dp));

		memset(r,0,sizeof(r));

		memset(l,0,sizeof(l));

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

		{

			scanf("%d",&tmp);

			dp[i] = tmp;

		}

		//算前綴

		l[0] = dp[0];

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

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

		

		//算後綴

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

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

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



		LL ans = 1;

		//嘗試砍每一個

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

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

		

		//砍頭砍尾

		ans = max(ans, max(r[1],l[n-2]));





		cout << ans << '\n';



		

	}

	

	



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.4050952388026268x):
// Created by Bingoo on 7/8/2020.

#include"bits/stdc++.h"

using namespace std ;

#define ll  long long

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);



template <class ...Args>

auto &see(const Args &...args) {return ((cerr << " " << args), ...) << '\n';}

#define bug(...)  cerr << "[ "#__VA_ARGS__" ] = "; see(__VA_ARGS__) << '\n';

//C++17

template<typename... Args>

void read(Args&... args){((cin >> args), ...);}

template<typename... Args>

void write(Args... args){((cout << args << " "), ...);}



ll mod = 1e6 +3 ;

ll power(ll a, ll b)	//a is base, b is exponent

{

    if (b == 0)

        return 1;

    if (b == 1)

        return a;

    if (b % 2 == 1)

        return (power(a, b - 1) * a) % mod;

    ll q = power(a, b / 2);

    return (q * q) % mod;

}



bool comp(pair<int,int>&a ,pair<int,int>&b)

{

    return a.second > b.second ;

}







int a ,b ,n ;







int main(){

    cin >> n ;



    int a[n];



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

        cin >> a[i] ;

    }



    int Prefix[n + 2];

    int Suffix[n + 2];



    Prefix[1] = a[0];

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

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

    }





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





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

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

    }





    int ans = max(Suffix[2], Prefix[n - 1]);



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

        ans = max(ans, __gcd(Prefix[i - 1], Suffix[i + 1]));

    }

    

    cout << ans << '\n' ;









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

#include<algorithm>

#include<string>

#include<cstdlib>

#include<map>

#include<iomanip>

#include<sstream>

#include<vector>

#include<stack>

#include<math.h>

using namespace std;



//ユークリッドの互除法　a,bは最大公約数を求めたい２つの数

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

	long long int tmp;

	long long int r = 1;

	if (b > a) {

		tmp = a;

		a = b;

		b = tmp;

	}

	r = a % b;

	while (r != 0) {





		a = b;

		b = r;

		r = a % b;



	}

	return b;

}





int main() {

	map<long long int, long long int>mp;

	//cout << fixed << setprecision(10);

	long long int n, m,v[200005],c[200005];

	long long dp[200005] = {}, dp2[200005] = {}, res = 0, cou = 0, memo, memo2;

	string str, str2;

	cin >> n;



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

		cin >> v[i];

		

	}

	memo = v[0];

	memo2 = v[1];

	if (n == 2) {

		cout << max(v[0], v[1]);

		return 0;

	}



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

		if (v[i] == memo) {

			cou++;

		}



	}



	if (cou== n-1) {

		cout << v[0];

		return 0;

	}

	cou = 0;

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

		if (v[i] == memo2) {

			cou++;

		}



	}



	if (cou == n - 1) {

		cout << v[1];

		return 0;

	}





	dp[0] = v[0];

	dp2[n - 1] = v[n - 1];

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

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

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

	}

	res = max(dp[n-2],dp2[1]);

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

		res = max(gcd(dp[i], dp2[i + 2]),res);

	}







	cout << res;

}


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

#include<algorithm>

#include<string>

#include<cstdlib>

#include<map>

#include<iomanip>

#include<sstream>

#include<vector>

#include<stack>

#include<math.h>

#include<queue>

#include<complex>

#include<random>

#include<ctime>

using namespace std;



//ユークリッドの互除法　a,bは最大公約数を求めたい２つの数

class Euclid_Gojyohou{

    public:

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

        long long int tmp;

        long long int r = 1;

        if (b > a) {

            tmp = a;

            a = b;

            b = tmp;

        }

        r = a % b;

        while (r != 0) {





            a = b;

            b = r;

            r = a % b;



        }

        return b;

    }

};





const long long int mod=1000000007;

const long long int INF=99999999999999999;



long long int n,l[200000],r[200000],a[200000],res=1;



int main() {

	cout << fixed << setprecision(18);

	Euclid_Gojyohou euc;

	cin>>n;

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

		cin>>a[i];

	}

	l[0]=a[0];

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

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

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

	}

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

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

	}

	res=max({res,l[n-2],r[1]});

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

        res=max(res,euc.gcd(l[i],r[i+2]));

    }

    cout<<res;

}
// Slower C++ solution:
typedef long long ll;

#include <bits/stdc++.h>

using namespace std;

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val){

    std::fill( (T*)array, (T*)(array+N), val );

}



std::map<pair<ll,ll>, ll> memo;

ll from_0[100010];

ll to_n[100010];







ll euclidean_gcd(ll a, ll b) {

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

  ll r;

  while ((r=a%b)) {

    a = b;

    b = r;

  }

  return b;

}



int main() {

    Fill(from_0,0);

    Fill(to_n,0);

    ll n;

    ll a[100010];

    std::cin >> n;

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

        std::cin >> a[i];

    }

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

        if(i==0){

            from_0[i] = a[i];

            to_n[n-1-i] = a[n-1-i];

        }else{

            from_0[i] = euclidean_gcd(from_0[i-1],a[i]);

            to_n[n-1-i] = euclidean_gcd(to_n[n-i],a[n-i-1]);

        }

    }

    ll result = 0;

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

        ll tmp;

        if(i==0){

            tmp = to_n[i+1];

        }else if(i==n-1){

            tmp = from_0[i-1];

        }else{

            tmp = euclidean_gcd(from_0[i-1],to_n[i+1]);

        }

        // std::cout << tmp << std::endl;

        result = max(result,tmp);

    }

    

    std::cout << result << std::endl;

}

// Faster C++ solution for the same problem (measured speedup: 2.5691662751158004x):
typedef long long ll;

#include <bits/stdc++.h>

using namespace std;



const int MAX = 510000;

 const int MOD = 1000000007;

 

 long long fac[MAX], finv[MAX], inv[MAX];

 

 // テーブルを作る前処理

 void COMinit() {

     fac[0] = fac[1] = 1;

     finv[0] = finv[1] = 1;

     inv[1] = 1;

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

         fac[i] = fac[i - 1] * i % MOD;

         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;

         finv[i] = finv[i - 1] * inv[i] % MOD;

     }

 }

 

 // 二項係数計算

 long long COM(int n, int k){

     if (n < k) return 0;

     if (n < 0 || k < 0) return 0;

     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;

 }

 

  long long modpow(long long a, long long n) {

      long long res = 1;

      while (n > 0) {

          if (n & 1) res = res * a % MOD;

          a = a * a % MOD;

          n >>= 1;

      }

      return res;

  }



vector<bool> isprime;





int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);

    

    ll n;

    std::cin >> n;

    vector<ll> a(n);

    ll g = 0;

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

        std::cin >> a[i];

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

    }

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

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

    

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

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

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

    }

    ll res = 0;

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

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

    }

    std::cout << res << std::endl;

}