#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<long long> data(n);
    for(int i=0;i<n;i++){
        if(i==0){
            cin>>data.at(i);
            continue;
        }
        if(i%2==1){
            int a;
            cin>>a;
            data.at(i)=data.at(i-1)-a;
            continue;
        }
        if(i%2==0){
            int a;
            cin>>a;
            data.at(i)=data.at(i-1)+a;
            continue;
        }
    }
    
    map<long long,long long> ma;
    ma[0]=1;
    long long count=0;
    for(int i=0;i<n;i++){
        if(ma.count(data.at(i))){
            count+=ma.at(data.at(i));
            ma.at(data.at(i))++;
        }else{
            ma[data.at(i)]=1;
        }
    }
    cout<<count<<endl;
}

#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
#include <sstream>
#define INF 1000000009
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int, int>;


int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    vector<ll> a(n);
    map<ll,ll> x;
    rep(i,n) {
        ll an;
        cin >> an;
        if(i==0) a[i] = an;
        else a[i] = an - a[i-1];
        if(a[i]==0) ans++;
        if(i%2==0) x[a[i]]++;
        else x[-1*a[i]]++;
    }
    for (const auto &i : x){
        ans += (i.second*(i.second-1)) / 2;
    }

    cout << ans << endl;
    return 0;
}