#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int> ;
#define rep(i,n) for(ll i=0;i<(n);i++)
ll min_ll(ll a,ll b){return a>=b ? b:a;}
ll max_ll(ll a,ll b){return a>=b ? a:b;}

int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i,n){
        ll m;
        cin >> m;
        if (i%2==0) a[i]=m;
        else a[i]=-m;
    }
    ll b[n+1]={0};
    ll ans =0;
    map<ll,ll> d;
    d[0]=1;
    for (int i=0;i<n;++i){
        b[i+1]=a[i]+b[i];
        if (!d.count(b[i+1])) d[b[i+1]]=1;
        else d[b[i+1]]++;
    }
    for (auto i = d.begin();i!=d.end();++i){
        ans+=i->second*((i->second)-1)/2;
    }
    cout << ans << endl;
}
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair <ll, ll> llll;

const int Maxn = 300005;

int n;
map <ll, ll> M;
ll res;

int main()
{
	scanf("%d", &n);
	llll cur = llll(0ll, 0ll);
	M[cur.first - cur.second]++;
	for (int i = 0; i < n; i++) {
		int a; scanf("%d", &a);
		if (i % 2 == 0) cur.first += a;
		else cur.second += a;
		res += M[cur.first - cur.second]++;
	}
	cout << res << endl;
    return 0;
}
