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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    long long prefix_sum = 0; // A[0] - A[1] + A[2] - A[3] + ...
    map<long long, int> count;
    count[0] = 1;
    long long ans = 0;
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) {
            prefix_sum += A[i];
        } else {
            prefix_sum -= A[i];
        }
        ans += count[prefix_sum];
        ++count[prefix_sum];
    }
    cout << ans << '\n';
    return 0;
}
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define eb emplace_back
using namespace std;
template <class T = int>
using V = vector<T>;
template <class T = int>
using VV = V<V<T>>;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<ld,ld>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    V<int> a(n);
    rep(i,n) cin >> a[i];
    V<ll> sum(n+1);
    rep(i,n){
        if(i%2==0) sum[i+1] = sum[i] + a[i];
        else sum[i+1] = sum[i] - a[i];
    }
    map<ll,ll> mp;
    rep(i,n+1){
        mp[sum[i]]++;
    }
    ll ans = 0;
    //rep(i,n+1) cout << sum[i] << ' ';
    //cout << endl;
    for(auto p : mp){
        //cout << p.first << ' ' << p.second << endl;
        ans += p.second*(p.second-1)/2;
    }
    cout << ans << endl;
}