#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0, length = n; i < length; i++)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ep emplace
#define epb emplace_back
#define scll static_cast<long long> 
#define sz(x) static_cast<int>((x).size())
#define pfll(x) printf("%lld\n", x)
#define ci(x) cin >> x
#define ci2(x, y) cin >> x >> y
#define ci3(x, y, z) cin >> x >> y >> z
#define ci4(w, x, y, z) cin >> w >> x >> y >> z
#define co(x) cout << x << endl
#define co2(x, y) cout << x << " " << y << endl
#define co3(x, y, z) cout << x << " " << y << " " << z << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> PQ;
typedef priority_queue<int, vector<int>, greater<int>> PQG;
typedef priority_queue<P> PQP;
typedef priority_queue<P, vector<P>, greater<P>> PQPG;

const int MAX_N = 3e5, MOD = 1e9 + 7, INF = 1e9;
int n, a[MAX_N];
map<ll, int> m;

int main() {
    ci(n);
    rep(i, n) ci(a[i]);
    ll sum = 0;
    m[0]++;
    rep(i, n) {
        sum += i % 2 ? a[i] : -a[i];
        m[sum]++;
    }
    ll ans = 0;
    for (auto &i: m) ans += scll(i.se - 1) * i.se / 2;
    co(ans);
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1e9+7LL;

int main() {
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    
    map<ll,ll> m;
    rep(i, N-1){
        A[i+1] -= A[i];
        if(i%2==1) A[i] *= -1;
        m[A[i]]++;
    }
    if((N-1)%2==1) A[N-1] *= -1; 
    m[A[N-1]]++;
    m[0]++;

    ll ans = 0;
    for (auto p : m) {
        auto key = p.first;
        auto value = p.second;
        ans += value*(value-1)/2;
    }
    cout << ans << endl;
}