#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<vii> vvii;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T=1, n;
    while (T--){
        cin >> n;
        ll ans = 0;
        vll acum(n,0);
        vi mxpos(n,0);
        ll mx = -1e18;
        ll pos = -1;
        for (int i = 0; i < n; ++i) {
            int aux; cin >> aux;
            acum[i] = aux;
            if (i) acum[i] += acum[i-1];
            if (acum[i] > mx){
                pos = i;
                mx = acum[i];
            }
            mxpos[i] = pos;
        }
        ll curr = 0;
        for (int i = 0; i < n; ++i) {
            ans = max(ans, curr + acum[mxpos[i]]);
            curr += acum[i];
        }
        cout << ans << "\n";
    }
}
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;

int main() {
  lint N;
  cin >> N;
  vector<lint> A(N);
  for(auto& elem : A) cin >> elem;

  P ans = {0,0};
  for(lint i=2; i<=1000; i++) {
    lint counter = 0;
    for(auto a : A) {
      counter += (a%i == 0);
    }
    ans = max(ans, P(counter, i));
  }
  cout << ans.second << endl;
}