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

int main() {
  long long s = 0, a, n;
  map<long long, long long> m;

  cin >> n;
  m[0] += 1;

  for (int i = 0; i < n; i++) {
    cin >> a;
    if (i % 2 == 0) s += a;
    else s -= a;

    m[s] += 1;
  }

  long long count = 0;
  for (auto i : m) {
    count += i.second * (i.second - 1) / 2;
  }

  cout << count << endl;

  return 0;
}
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
   #include <atcoder/all>
   using namespace atcoder;
#endif
#define all(v) v.begin(), v.end()
using in = long long;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const in INF=(in)1e18+7;
const in inf=max(in(1e18)+7,in(1e9)+7);
using P=pair<in,in>;
using T=tuple<in,in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};
template <typename Typ>
bool chmin(Typ &a, const Typ& b) {if (a > b) {a = b; return true;} return false;}
template <typename Typ>
bool chmax(Typ &a, const Typ& b) {if (a < b) {a = b; return true;} return false;}
template <typename Typ>
Typ ceil(Typ x, Typ y){return (x+y-1)/y;}
#ifdef  _DEBUG
    #define debug(x) cout<<"debug:"<<x<<endl
    #define vdebug(x) cout<<"debug:";\
                      for(auto asdf:x) cout<<asdf<<" ";\
                      cout<<endl
#else
    #define debug(x) 
    #define vdebug(x) 
#endif
#define CASE(x) cout<<"Case #"<<x<<": "

int main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
//cout << fixed << setprecision(12);
    in n;  cin>>n;
    vector<in> a(n);
        rep(i,n) cin>>a[i];
    vector<in> b(n);
    map<in,in> mp0,mp1;
    set<in> st0,st1;
    rep(i,n){
        if(i==0) b[i]=a[i];
        else{
            b[i] = a[i]-b[i-1];
            if(i%2==0) mp0[b[i]] ++;
            else mp1[b[i]] ++;
        }
    }

    in cnt=0,sum=0;
    for(in i=0;i<n-1;i++){
        cnt += mp0[sum]+mp1[-sum];
        if((i+1)%2==0) mp0[b[i+1]] --;
        else mp1[b[i+1]] --;
        if(i%2==0) sum += a[i];
        else sum -= a[i];
    }
    cout<<cnt<<"\n";
    
}/*
./problem.exe
*/