#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << '\n'
typedef long long ll;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
//const ll MOD = 998244353;

template <typename T> inline bool chmax(T &a, T b) {return a < b ? a = b, true : false;}
template <typename T> inline bool chmin(T &a, T b) {return a > b ? a = b, true : false;}

void solve(){
    int n;  cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<ll> c(n + 1, 0LL), d(n + 1, 0LL);
    for (ll i = 0; i < n; i++) {
        if(i % 2 == 0){
            c[i + 1] = c[i] + a[i];
            d[i + 1] = d[i];
        }
        else{
            c[i + 1] = c[i];
            d[i + 1] = d[i] + a[i];
        }
    }
 
    map<ll,ll> mp;
    for (ll i = 0; i < n + 1; i++) mp[c[i] - d[i]]++;
 
    ll ans = 0;
    for (auto p : mp) {
        ll w = p.second;
        ans += w * (w-1) / 2;
    }
    print(ans);
    return;
}

int main() { 
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(18);

    int t;
    //cin >> t;
    t = 1;

    while(t--) solve();
    return 0;
}
#include"bits/stdc++.h"
using namespace std;

vector<string> split(const string & s, char c=' ') {
   vector<string> v; stringstream ss(s); string x;
   while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
   stringstream s; s << "[";
   for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
   s << arr[n - 1] << "]";
   return s.str();
}
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; } 
template<typename T, typename... Args>
inline void __evars(vector<string>::iterator it, T a, Args... args) {
   cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
   __evars_out_var(a);
   cerr << "; ";
   __evars(++it, args...);
}
template<typename T>
void maxa(T &a,T b){
  if(a<b) a=b;
}
template<typename T>
void mina(T &a,T b){
  if(a>b) a=b;
}

#define int long long
#define ll int
// const int inf=1e18;
#define F first
#define S second
#define Z(c) (int)(c).size()
#define pii pair<int,int>
const int mod=1e9+7;
const int N=2e5+10;

 vector<int> adj[N];
 int ct,vt[N];

 void dfs(int x){
     if(vt[x]) return;
     vt[x]=1;
     ct++;
     for(int i:adj[x]) dfs(i);
 }

void boomer(){
  int n; cin>>n;
  vector<int> v(n);
  for(int &x:v) cin>>x;

  int lt=0,rt=n-1;
  
  while(lt<rt){
      if(v[lt]!=v[rt]){
         adj[v[lt]].push_back(v[rt]);
         adj[v[rt]].push_back(v[lt]);
      }
      lt++;
      rt--;
  }

  int ans=0;

  for(int x:v){
      ct=0;
      dfs(x);
      ans+=max(0LL,ct-1);
  }

  cout<<ans;

}

  signed main()
  { 
  ios_base::sync_with_stdio(0); cin.tie(0); 

  int tc=1;

  // cin>>tc; 
  for(int i=1;i<=tc;++i)
  { 
  // cout<<"Case #"<<i<<": ";
  boomer();
  if(i<tc)
  cout<<"\n";
  }

  return 0; 
  }
