#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
};
#define imie(...)"Line: "<<__LINE__<<" -> " " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
#define int long long
vector<int> a;
int sz;
int calc(vector<int> &arr, bool pari){
    map<int, int> mappa;
    int ans = 0;
    int n = (int)arr.size();
    vector<int> pref(n + 1);
    for(int i = 1; i <= n; i++){
        if(i == 1){
            pref[i] = arr[i - 1];
        }
        else{
            pref[i] = arr[i - 1] + pref[i - 1];
        }
    } 
    debug() << imie(arr) imie(pref) imie(pari);
    for(int i = 1; i <= n; i++){
        if(pref[i] == 0){
            ans++;
        }
        int posizione = sz + 1;
        if(pari){
            posizione = i * 2 + 1; 
        }
        else{
            posizione = i * 2 + 2;
        }
        if(posizione <= sz){
            int currp = pref[i] + a[posizione];
            debug() << imie(posizione) imie(a[posizione]) imie(i) imie(pari);
            ans += mappa[currp];
            ans += (currp == 0 ? 1 : 0);
        }
        ans += mappa[pref[i]];
        mappa[pref[i]]++;
    }
    return ans;
}
int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n;
    cin >> n;
    sz = n;
    vector<int> dispari, pari;
    a.resize(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i < n; i += 2){
        dispari.push_back(a[i] - a[i + 1]);
    }
    for(int i = 2; i < n; i += 2){
        pari.push_back(a[i] - a[i + 1]);
    }
    debug() << imie(dispari) imie(pari);
    int ans = calc(pari, false) + calc(dispari, true);
    cout << ans << '\n';
}


    


#include <bits/stdc++.h>
using namespace std;
 
#define M1 1000000007
#define M2 998244353
#define INF 1e18
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<int>
#define vlli vector <long long>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
 
/********************************************************************/
const double pi = 3.1415926535;
/********************************************************************/
//FAST IO//
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
 
 
/********************************************************************/
int main()
{
  FAST();
 
  int n; cin>>n; vi a(n); forr(i,n) {cin>>a[i]; }
  
  map <int, int> M;
  for (int i=0; i<n; i++)
  {
    int x=a[i];
    for (int i=2; i*i<x; i++)
    {
      if (x%i==0){ M[i]++;}
      while (x%i==0) {x/=i; }
    }
    if (x!=0 && x!=1){M[x]++; }
    
  }
  
  auto it=M.begin();
  int stor=-1;
  int ans=0;
  while (it !=M.end())
  {
    if ((*it).S > ans) {stor=(*it).F; }
    ans=max(ans, (*it).S);
    it++;
  }
 cout<<stor<<endl;
}
