#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define int long long int
#define popcount(x) __builtin_popcountll(x)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define fr first
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define ld long double
const int INF = __LONG_LONG_MAX__;
#define rall(a) (a).rbegin(),(a).rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroint-loops")

int power(int b,int e,int m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
int power( int b, int e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(int x)
{
    // x wiint check if x == 0 and !(x & (x - 1)) wiint check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}


void solve()
{
   int n;
   cin>>n;
   vector <int> v(n);
   for(auto &i:v) cin>>i;
   	int x=0,y=0,curr=0;
   for(int i=2;i<=1000;i++)
   {
   	  x=0;
   	  for(int j=0;j<n;j++)
   	  {
   	  	if(v[j]%i==0)
   	  		x++;
   	  }
   	  // cout<<y<<"\n";
   	  if(x>curr)
   	  {
   	  	curr=x;
   	  	y=i;
   	  }
   }
   cout<<y;
}


signed main()
{
  fastio
  int tt=1;
  // cin>>tt;
   // freopen("input.txt", "r" , stdin);
  // freopen("output.txt", "w", stdout);
  while(tt--)
  {
      solve();
      cout<<"\n";
  }
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll M1 = 1e9+7;
void files(){
 freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);

}
void fast(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

}
int main(){
  fast();
  ll n;
  cin>>n;
  vector<ll> d(n,0);
  vector<ll> sum(n+1,0);
  vector<ll> m(n+1,0);
  for(int i=0; i<n; i++){
    cin>>d[i];
    sum[i+1]=sum[i]+d[i];
    m[i+1]=max(m[i],sum[i+1]);
  }

  ll c=0,ans=0;
  for(int i=1; i<=n; i++){
    ll k=c+m[i];
    ans=max(ans,k);
    c=c+sum[i];
  }
  cout<<ans;
  return 0;
}