#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define ms memset
#define pb push_back
#define F first
#define S second
ll MOD = 1000000007;
ll INF = 1000000000;
 
ll power(ll base, ll n){
	if (n == 0) return 1;
	if (n == 1) return base;
	ll halfn = power(base, n/2);
	if (n % 2 == 0) return (halfn * halfn) % MOD;
	return (((halfn * halfn) % MOD) * base) % MOD;
}
 
ll inverse(ll n){
	return power(n, MOD-2);
}
 
ll add(ll a, ll b){
	return (a+b) % MOD;
}
 
ll mul(ll a, ll b){
	return (a*b) % MOD;
}
 
ll gcd(ll a, ll b){
	if (a == 0) return b;
	if (a == 1) return 1;
	return gcd(b%a, a);
}
 
int main(){
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    FOR(i, 0, n){
    	cin >> a[i];
    	if (i % 2 == 1){
    		a[i] = 0 - a[i];
		}
	}
	vector<ll> A(n+1);
	map<ll, ll> mp;
	mp[0] = 1;
	ll ans = 0;
	FOR(i, 1, n+1){
		A[i] = A[i-1] + a[i-1];
		ans += mp[A[i]];
		mp[A[i]]++;
	}
	cout << ans << '\n';
	return 0;
}

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

int main() {
    using ll = long long;
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    vector<ll> sums(n + 1);
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            sums[i + 1] = sums[i] + a[i];
        } else {
            sums[i + 1] = sums[i] - a[i];
        }
    }

    map<ll, ll> mp;
    for (int i = 0; i <= n; i++) mp[sums[i]]++;

    ll ans = 0;

    for (auto m: mp) ans += (m.second - 1) * m.second / 2;

    cout << ans << endl;
}