#include <bits/stdc++.h>

#define kyou using
#define mo namespace
#define kawaii std
 
kyou mo kawaii; // hi honey~
 
#define ll long long
#define ld long double
#define endl "\n"
const int MX = 100005;
const int LG = (int)log2(MX) + 1;
const int BLOCK = 205;
const int inf = 1000000069;
const ll inf_ll = 8000000000000000069ll;
const ll mod = 1000000007;
const int alpha = 30;
const int dxh[] = {1, 1, -1, -1, 2, 2, -2, -2};
const int dyh[] = {2, -2, 2, -2, 1, -1, 1, -1}; // horse
const int dx[] = {1, -1, 0, 0, 0, 0};
const int dy[] = {0, 0, 1, -1, 0, 0}; // adj
const int dz[] = {0, 0, 0, 0, 1, -1}; // 3d
const int dxd[] = {1, 1, 1, 0, -1, -1, -1, 0};
const int dyd[] = {1, 0, -1, -1, -1, 0, 1, 1}; // diag
mt19937 rng(time(NULL));
 
bool untied = 0;
void setIn(string s){freopen(s.c_str(), "r", stdin);}
void setOut(string s){freopen(s.c_str(), "w", stdout);}
void unsyncIO(){cin.tie(0) -> sync_with_stdio(0);}
void setIO(string s = ""){
    if(!untied) unsyncIO(), untied = 1;
    if(s.size()){
        setIn(s + ".in");
        setOut(s + ".out");
    }
}

map<ll, int> mp[2];

int main(){
	setIO();

	int n; cin >> n;
	vector<ll> v(n);
	for(int i = 0; i < n; i ++)
		cin >> v[i];

	vector<ll> owo(n + 1);
	owo[n] = 0; mp[n % 2][0] ++;
	for(int i = n - 1; i >= 0; i --){
		owo[i] = v[i] - owo[i + 1];
		mp[i % 2][owo[i]] ++;
	}

	ll ans = 0ll;

	for(int tp = 0; tp < 2; tp ++)
		for(auto i : mp[tp])
			ans += i.second * 1ll * (i.second - 1) / 2;

	for(auto i : mp[0]){
		int cntL = i.second, cntR = mp[1][-i.first];
		ans += cntL * 1ll * cntR;
	}
	
	cout << ans << endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define fo(a,b) for(int64_t a=0;a<b;a++)
#define sor(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define ll int64_t
#define mod 1000000007
#define vl vector<int64_t>
#define vc vector<char>
#define vs vector<string>
#define np(vec) next_permutation(vec.begin(),vec.end())==true
#define en endl
#define vvl vector<vector<int64_t>>
#define stl stack<int64_t>
#define qul que<int64_t>
#define ms(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pq priority_queue
#define pql priority_queue<int64_t>
#define pu push
#define pop pop()
#define top top()
#define pqr priority_queue<ll,vector<ll>,greater<ll>>
#define co cout
#define ci cin
#define wh while
#define size size()
#define front front()

int main() {
 ll n,a;
  cin>>n;
  vl vec(n);
  fo(i,n){
    cin>>a;
    if(i%2==0){vec.at(i)=a;}
    else{vec.at(i)=-a;}
  }
  ll s=0;
  vl list;
  fo(i,n){
    s+=vec.at(i);
    list.push_back(s);
  }
  list.push_back(0);
   list.push_back(pow(10,17));
  sor(list);
  ll t=1;
  vl ans;
  fo(i,n+1){
    if(list.at(i)==list.at(i+1)){t++;}
    else{
      
      ans.push_back(t);
      t=1;
    }
  }
  ll si=ans.size;
  ll k=0;
  fo(i,si){
    k+=ans.at(i)*(ans.at(i)-1)/2;
  }
  cout<<k<<en;
}