#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<chrono>
#include<random>
#include<iterator>
#include<map>
#include<list>
#include<algorithm>
#include<fstream>
#include<unordered_map>
#include<set>
#include<queue>
using namespace std;

#define pb  push_back
#define mp  make_pair
#define FF  first
#define SS  second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define mod 1e9+7
#define all(v) (v).begin(),(v).end()
#define ps(x,y) fixed<<setprecision(y)<<x

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef map<ll,ll> mll;

ll gcd(ll a,ll b){  //gives gcd of a,b (a<b)
  if(a==0)  return b;   //Base Case
  return gcd(b%a,a);
}

ll lcm(ll a,ll b){  //gives lcm of a,b by (a*b)/gcd(a,b)
  return a/gcd(a,b)*b;
}

ll gcd_ext(ll a,ll b,ll&x,ll&y){  //Extended Euclidean Algorithm
  if(a==0){   //Base Case
    x=0;    y=1;
    return b;
  }
  ll x1,y1;   //To store recursive call
  ll gcd=gcd_ext(b%a,a,x1,y1);
  x=y1-(b/a)*x1;    //Updating x,y from recursive call
  y=x1;
  return gcd;
}

ll power_mod(ll a,ll b,ll c=mod){
	ll res=1;
	while(b){
		if(b&1){    //Checking last bit 1
			res=(res*a)%c;
			b--;
		}
		a=(a*a)%c;    //Updating a
		b=b>>1;     //Right shift b by 1
	}
	return res;
}

ll multi_mod_inv(ll a,ll m){
  ll x,y;
  ll gcd=gcd_ext(a,m,x,y);
  if(gcd!=1)  return -1;
  x=(x%m+m)%m;
  return x;
}

ll mod_div(ll a,ll b,ll m){ //(a/b)mod m?
  if(multi_mod_inv(b,m)!=-1)  return (a%m*multi_mod_inv(b,m)%m)%m;
  else  return -1;
}

bool str_pall(string str){
  ll sz=str.size();
  loop(i,0,sz/2)  if(str[i]!=str[sz-1-i])  return 0;
  return 1;
}

signed main()
{
    IOS;
    ll test=1;
    //cin>>test;
    while(test--)
    {
      ll n;
      cin>>n;
      vll v(n);
      loop(i,0,n) cin>>v[i];
      mll m;
      m[0]++;
      ll sum=0,order=1;
      loop(i,0,n){
        sum+=order*v[i];
        m[sum]++;
        order*=-1;
        //cout<<"m["<<sum<<"] = "<<m[sum]<<endl;
      }
      //cout<<endl<<endl;
      mll:: iterator it;
      ll ans=0;
      for(it=m.begin();it!=m.end();it++){
        //cout<<"m["<<it->FF<<"] = "<<it->SS<<endl;
        ll temp=it->SS;
        ans+=(temp*(temp-1)/2);
      }
      cout<<ans<<endl;
    }
}

#include <iostream>
#include <map>
using namespace std;

long long N, Answer = 0;
long long A[1 << 19], B[1 << 19], C[1 << 19];
map<long long, long long> D;

int main() {
	// Step #1. 入力
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];

	// Step #2. 累積和を取る
	for (int i = 1; i <= N; i++) {
		if (i % 2 == 1) B[i] = A[i];
		if (i % 2 == 0) B[i] = -A[i];
		C[i] = C[i - 1] + B[i];
	}

	// Step #3. 答えを計算する
	for (int i = 0; i <= N; i++) {
		Answer += D[C[i]];
		D[C[i]] += 1;
	}
	cout << Answer << endl;
	return 0;
}