#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
//#include <set>
using namespace std;
typedef long long LONG;
 
 
 
LONG gcd(LONG x, LONG y) {
    if(x % y == 0) {
        return y;
    } else {
        return gcd(y, x % y);
        //x%y==0でないときはユーグリットの互除法を使って再帰的に関数を呼び出す。
    }
}
void print(vector<int>A){
    for(size_t i=0;i<A.size();i++){
        if(A[i]==1){
            cout<<'(';
        }else{
            cout<<')';
        }
    }
}
 
bool comp1(pair<int,int> lhs, pair<int,int>rhs) {
    return lhs.first<rhs.first;
}
 
bool comp2(pair<string,int> lhs, pair<string,int>rhs) {
    return lhs.second<rhs.second;
}
void solve(int min,int max,vector<int>&A,int B){
    if(min+1==max){
        cout<<std::min(A[max]-B,B-A[min])<<endl;
        return;
    }
    int a=(min+max)/2;
    if(A[a]<B){
        solve(a,max,A,B);
    }else{
        solve(min,a,A,B);
    }
    
    
    
}
LONG pow2(LONG a,LONG b){
    LONG res=1;
    for(int i=0;i<b;i++){
        res=res*a;
    }
    return a;
}

void solve1(vector<bool>&A,vector<LONG>&C,int pos,vector<vector<pair<int,LONG>>>&path){
    for(int i=0;i<path[pos].size();i++){
        if(!A[path[pos][i].first]){
            A[path[pos][i].first]=true;
            C[path[pos][i].first]=C[pos]^path[pos][i].second;
            solve1(A,C,path[pos][i].first,path);
        }
    }
}

const LONG mod=1000000007;
int main() {
    int N;
    cin>>N;
    vector<LONG>A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    vector<LONG>B(N);
    B[0]=A[0];
    map<LONG,LONG>C;
    map<LONG,LONG>D;
    C[A[0]]=1;
    for(int i=1;i<N;i++){
        B[i]=A[i]-B[i-1];
        if(i%2==0){
            if(C.count(B[i])==0){
                C[B[i]]=1;
            }else{
                C[B[i]]++;
            }
        }else{
            if(D.count(B[i])==0){
                D[B[i]]=1;
            }else{
                D[B[i]]++;
            }

        }
        
    }
    LONG result=0;
    for(int i=1;i<N+1;i++){
        if(i%2==0){
            result+=C[-B[i-1]];
            result+=D[B[i-1]]-1;

        }else{
            result+=C[B[i-1]]-1;
            result+=D[-B[i-1]];

        }
    }
    result=result/2;
    
    result+=C[0]+D[0];
    cout<<result<<endl;
    
    

    
    
    return 0;
    
 
}

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

#define int long long
const int N = 3e5 + 5;

int n;
int a[N];
map<int , int> mp;

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