#include <bits/stdc++.h>
using namespace std;
#define For(Ti,Ta,Tb) for(int Ti=(Ta);Ti<=(Tb);++Ti)
#define Dec(Ti,Ta,Tb) for(int Ti=(Ta);Ti>=(Tb);--Ti)
#define Debug(...) fprintf(stderr,__VA_ARGS__)
using ll=long long;
mt19937 eng(chrono::system_clock::now().time_since_epoch().count());
template<typename T> T Rand(const T &_l,const T &_r){return uniform_int_distribution<T>(_l,_r)(eng);}
vector<pair<ll,int>> PrimeFac(ll _x){
vector<pair<ll,int>> _res;
auto _add=[&](int _i){
if(_x%_i==0){
_res.emplace_back(_i,0);
while(_x%_i==0) ++_res.back().second,_x/=_i;
}
};
_add(2),_add(3);
for(int _i=5;1LL*_i*_i<=_x;_i+=6) _add(_i),_add(_i+2);
if(_x>1) _res.emplace_back(_x,1);
return _res;
}
vector<ll> Divisors(ll _x){
vector<ll> _res;
for(int _i=1;1LL*_i*_i<=_x;++_i) if(_x%_i==0){
_res.push_back(_i);
if(1LL*_i*_i!=_x) _res.push_back(_x/_i);
}
return _res;
}
const int N=1e6+5;
int n;ll a[N];
int main(){
ios::sync_with_stdio(false),cin.tie(nullptr);
cin>>n;
For(i,1,n) cin>>a[i];
ll ans=1;
For(_,1,12){
int i=Rand(1,n);
auto pf=PrimeFac(a[i]);
auto div=Divisors(a[i]);
sort(div.begin(),div.end(),greater<ll>());
map<ll,int,greater<ll>> cnt;
For(j,1,n) ++cnt[__gcd(a[j],a[i])];
for(auto x:pf) for(ll y:div) if(a[i]%(y*x.first)==0) cnt[y]+=cnt[y*x.first];
for(auto x:cnt){
if(ans>x.first) break;
if(x.second>=(n+1)/2){
ans=max(ans,x.first);break;
}
}
}
cout<<ans<<'\n';
#ifdef zyz
Debug("Elapsed time: %dms\n",int(clock()));
#endif
return 0;
}//16767234565894488865
1042A - Benches | 1676B - Equal Candies |
1705B - Mark the Dust Sweeper | 1711A - Perfect Permutation |
1701B - Permutation | 1692A - Marathon |
1066A - Vova and Train | 169B - Replacing Digits |
171D - Broken checker | 380C - Sereja and Brackets |
1281B - Azamon Web Services | 1702A - Round Down the Price |
1681C - Double Sort | 12A - Super Agent |
1709A - Three Doors | 1680C - Binary String |
1684B - Z mod X = C | 1003A - Polycarp's Pockets |
1691B - Shoe Shuffling | 1706A - Another String Minimization Problem |
1695B - Circle Game | 1702B - Polycarp Writes a String from Memory |
1701A - Grass Field | 489C - Given Length and Sum of Digits |
886B - Vlad and Cafes | 915A - Garden |
356A - Knight Tournament | 1330A - Dreamoon and Ranking Collection |
1692B - All Distinct | 1156C - Match Points |