#include <algorithm>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_set>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; ++i)

using namespace std;
using LLONG = long long;
const LLONG MOD = 998244353;

// 番号が若い順から順に０にしていくと
// 偶数番・奇数番をそれぞれ独立に足し合わせたものが残っていく
// -> 偶数番の合計と奇数番の合計が等しくなればよい
// -> 偶数番と奇数番の差を計算し，等しくなればよい

int main()
{
	int N; cin >> N;
	vector<LLONG> as(N); REP(i, N) cin >> as[i];
	vector<LLONG> diffs(N);
	diffs[0] = as[0];
	for(int i = 1; i < N; ++i)
	{
		if (i % 2 == 0) diffs[i] = diffs[i - 1] + as[i];
		else diffs[i] = diffs[i - 1] - as[i];
	}

	map<LLONG, LLONG> diff2NumMap;
	for (LLONG diff : diffs) ++diff2NumMap[diff];

	LLONG ans = 0;
	++diff2NumMap[0];
	for (const auto& kvp : diff2NumMap)
	{
		LLONG num = kvp.second;
		ans += num * (num - 1) / 2;
	}

	cout << ans << endl;
}

#include<bits/stdc++.h>
#include <iostream>
#include <stack>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

using ll = long long;

using ull = unsigned long long;

using pi=pair<int,int>;

using pl=pair<ll,ll>;

#define pb push_back



#define     f               first
#define     s               second
#define     rep(i,a,b)      for(ll i=a;i<b;i++)
#define     repd(i,b,a)     for(ll i=b;i>a;i--)
#define     repi(i,b,a,c)   for(ll i=b;i<a;i+=c)
#define     cas             ll cas;cin>>cas ; for(ll i=0;i<cas;i++)

const ll N=1e5 + 10;
const ll INF=1e18;
const ll M=1e5 +10;
const ll mod=1e9 + 7;
const ll L=31;
const ll hp=293;


ll _pow(ll a,ll b){
    if(b==0){
      return 1;
    }
    if(b==1){
      return a%mod;
    }
    ll k=_pow(a,b/2);
    k%=mod;
    k=k*k;
    k%=mod;
    if(b%2==1){
      k*=a;
      k%=mod;
    }
    return k;
}


bool prime[N];
ll seive(){
     for(ll i=0;i<N;i++){
          prime[i]=true;
     }
     for(ll i=2;i<=sqrt(N);i++){
          if(prime[i]){
               for(ll j=i*i;j<N;j+=i){
                    prime[j]=false;   
               }
          }
     }
     
}




ll solve(){
     // seive();
     ll n;
     cin>>n;
     // ll cnt=0;
     set<ll>st;
     for(ll i=2;i<=sqrt(n);i++){
          // if(prime[i]){
               // cout<<i<<" ";
               ll p=i*i;
               while(p<=n){
                    st.insert(p);
                    p=p*i;
                    // cnt++;
               }
          // }
     }
     ll sz=st.size();
     cout<<(n-sz)<<'\n';
    return 0;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    //solve();
//    cas{
        solve();
//    }
    return 0;
}