//IQ134高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}



int main() {
	ll ans = 0;
	ll tmp = 0;
	int n; cin >> n;
	vector<ll> a(n);
    cin >> a;
    map<ll, ll> m;
    m[0]++;
    REP(i, n){
        if(i%2==0)tmp += a[i];
        else tmp -= a[i];
        m[tmp]++;
    }
    for(auto it = m.begin(); it != m.end(); it++){
        ans += (it->second) * (it->second - 1LL) / 2;
    }
	cout << ans << endl;
}
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>
#include <limits>
#include <math.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define Pll pair<long,long>
#define mp make_pair
#define INF 1000000001
#define INFl 1000000000000000001
#define ll long long
using namespace std;


struct edge{long to,cost,k;};

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    int N;cin>>N;
    vector<long>A(N);
    vector<long>B(N);
    rep(i,N)cin>>A[i];
    map<long,int> mp;
    B[0]=A[0];
    rep(i,N-1){
        B[i+1]=A[i+1]-B[i];
    }
    B[0]=0;
    mp[0]=1;
    long cnt=0;
    rep(i,N-1){
        //cout<<B[i+1]<<endl;
        long j=B[i+1];
        if(i%2==0){
            if(mp.count(-j))cnt+=mp[-j];
        }else{
            if(mp.count(j))cnt+=mp[j];
        }

        if(i%2==0){
            long k=A[i+1]-B[i+1];
            if(mp.count(k))mp[k]++;
            else mp.emplace(k,1);
        }else{
            long k=A[i+1]-B[i+1];
            if(mp.count(-k))mp[-k]++;
            else mp.emplace(-k,1);
        }
    }
    cout<<cnt<<endl;
}