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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    rep(i,N) if(i & 1) A[i] = -A[i];
    vector<ll> s(N + 1, 0);
    rep(i,N) s[i + 1] = s[i] + A[i];
    map<ll,ll> mp;
    rep(i,N+1) mp[s[i]]++;
    ll ans = 0;
    for(auto e : mp){
        ll num = e.first;
        ll cnt = e.second;
        ans += cnt * (cnt - 1) / 2;
    }
    cout << ans << endl;
}
#pragma GCC optimize ("O2")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<iostream>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}
ll num[524310];
const ll dekai = 1ll << 60;
int kazu[524310];
const int ma = (1 << 19) - 1;
int query(ll n) {
	int n2 = (n & ma) | 1;
	while (num[n2]) {
		if (num[n2] == (n | dekai)) return kazu[n2];
		n2 = n2 * 2 % 524309;
	}
	return 0;
}
void add(ll n) {
	int n2 = (n & ma) | 1;
	while (num[n2]) {
		if (num[n2] == (n | dekai)) {
			kazu[n2]++;
			return;
		}
		n2 = n2 * 2 % 524309;
	}
	num[n2] = n | dekai;
	kazu[n2] = 1;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N = getint();

	add(0);
	ll kotae = 0;
	ll ima = 0;
	int pn = 1;
	rep(i, N) {
		ima += pn * getint();
		kotae += query(ima);
		add(ima);
		pn = -pn;
	}

	co(kotae);

	Would you please return 0;
}