#include <iostream>
#include <cmath>
#include <stdio.h>
#include <string.h>
#include <bits/stdc++.h>
#include <vector>
#include <array> 
#include <tuple>
using namespace std; 

int main(){
  long int N;
  cin >> N;
  int p=1;
  long long a;
  vector<long long> B(N);
  for (int i=0; i<N; i++){
    cin >> a;
    B[i]=p*a;
    p=-p;
  }
  vector<long long> S(N+1);
  S[0]=B[0];
  for (int i=1; i<N; i++){
    S[i]=S[i-1]+B[i];
  }
  S[N]=0;
  sort(S.begin(), S.end());
  long long M=0;
  long int m=1;
  for (int i=1; i<N+1; i++){
    if ((i==N)&(S[i]==S[i-1])){
      m++;
      M=M+(m*(m-1))/2;
    }
    else if (S[i]==S[i-1]){
      m++;
    }
    else {
      M=M+(m*(m-1))/2;
      m=1;
    }
  }
  cout << M << endl;
}
#include<bits/stdc++.h> 
#define cpu() ios::sync_with_stdio(false); cin.tie(nullptr)
#define ps() cout << "\n"
#define pb push_back
#define ff first
#define ss second

typedef long long ll;

using namespace std;
const int MOD = 1e9 + 7, MOD1 = (119 << 23) | 1;
const int INF = 1e9 + 5, MAX = 2e5 + 5; 
int main(){
   cpu();
   int n; cin >> n; 
   map<ll, int> m;
   ll cur[2] = {};
   ll ans = 0;
   m[0] = 1;
   for(int i = 0; i < n; i++){
      ll x; cin >> x;
      cur[i & 1] += x;
      ans += (m[cur[1] - cur[0]]++);
   }
   cout << ans << "\n";
   return 0;
}