#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
#define rep(i,n) for(int i=0;i<n;i++)
using P=pair<int,int>;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) scanf("%d",&a[i]);
  
  vector<ll> e(n);
  vector<ll> o(n);
  rep(i,n){
    if(i%2) o[i]=a[i];
    else e[i]=a[i];
  }
  rep(i,n-1) e[i+1]+=e[i];
  rep(i,n-1) o[i+1]+=o[i];
  
  vector<ll> b(n+1);
  rep(i,n) b[i]=e[i]-o[i];
  n++;
  sort(b.begin(),b.end());
  
  ll ans=0;
  int i=0;
  while(i<n){
    ll k=b[i];
    ll c=0;
    while(b[i]==k){
      i++; c++;
      if(i==n) break;
    }
    ans+=c*(c-1)/2;
  }
  
  cout << ans << endl;
  
}
#include <bits/stdc++.h>
#define int long long
#define mod 1000000007

using namespace std;

map <int, int> d;
main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    vector <int> a(n + 1);
    int ans = 0;
    d[0] = 1;
    for (int i = 1; i <= n; ++ i){
        cin >> a[i];
        a[i] -= a[i - 1];
        if (i & 1) ans += d[a[i]];
        else ans += d[-a[i]];
        if (i & 1) d[a[i]] += 1;
        else d[-a[i]] += 1;
    }
    cout << ans;
}
