/* これを翻訳している間、あなたはあなたの人生のいくつかの貴重な瞬間を無駄にしました */

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ld long double
#define mem(x,y) memset(x,y,sizeof x)

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	int n;
	cin>>n;
	ll s[2]={0,0};
	map<ll,int> m;
	ll ans=0;
	m[0]=1;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		s[i%2]+=a;
		ans += m[s[0]-s[1]];
		m[s[0]-s[1]]++;
	}
	cout<<ans<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return ;
}

typedef unsigned long long uLL;
typedef long long LL;

LL a[300010], t[300010];
LL n, ans;

int lowbit(int x) { return x & -x; }

void modify(int x, LL d) {
    while (x <= n) {
        t[x] += d;
        x += lowbit(x);
    }
    return ;
}

LL query(int x) {
    LL s = 0;
    while (x) {
        s += t[x];
        x -= lowbit(x);
    }
    return s;
}

int main() {
    read(n);
    for (int i = 1; i <= n; ++i)    read(a[i]);
    for (int i = n; i >= 1; --i) {
        ans += query(a[i] + 1);
        modify(a[i] + 1, 1);
    }
    printf("%lld\n", ans);
    for (int i = 1; i < n; ++i) {
         ans = ans + n - a[i] - a[i] - 1;
         printf("%lld\n", ans);   
    }
    return 0;
}