#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    map<ll,ll> mp;
    ll a;
    ll po = 1;
    ll tmp = 0;
    REP(i,N){
        cin >> a;
        A[i] = po * a;
        po *= -1;
        tmp += A[i];
        if(mp.count(tmp)) mp[tmp] ++;
        else mp[tmp] = 1;
    }

    ll ans = 0;
    tmp = 0;
    REP(i,N-1){
        if(mp.count(tmp)) ans += mp[tmp];
        tmp += A[i];
        mp[tmp] --;
    }

    cout << ans << endl;

    return 0;
}
#include<iostream>
#include<cstdio>
#include<map>
#include<bitset>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<ctime>
using namespace std;
#define M 300005
#define N 1000005
#define MP make_pair
#define debug() cerr<<"Why So Serious?"<<endl
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T>void Rd(T &x){
	x=0;static char c;
	while(c=getchar(),c<48);
	do x=(x<<1)+(x<<3)+(c^48);
	while(c=getchar(),c>47);
}
int n;
int A[M];
int Sum[2][M];
map<ll,int>S;
int main(){
	Rd(n);
	int a=0;
	ll sum0=0,sum1=0;
	ll ans=0;
	S[0]=1;
	for(int i=1;i<=n;++i){
		Rd(a);
		if(i&1)sum1+=a;
		else sum0+=a;
		ll res=sum1-sum0;
		if(S.find(res)!=S.end())ans+=S[res];
		else if(S.find(res)==S.end())S[res]=0;
		S[res]++;
	}
	printf("%lld\n",ans);
	return 0;
}