#include <bits/stdc++.h>
 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef long int li;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define test ll t; cin >> t; while(t--)
const long long int dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0}; 
const long long int cons = 100005;
const long long int MOD = 1000000007; // const long long int MOD = 998244353; 
const long long int const_INT_MAX = 1000000000000000000, const_INT_MIN = -1 * 1000000000000000000;
using namespace std;
bool sortinrev(const pair<ll,ll> &a, const pair<ll,ll> &b){return (a.first > b.first);}
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b){return (a.second < b.second);}
bool sortbysecinrev(const pair<ll,ll> &a, const pair<ll,ll> &b){return (a.second > b.second);}
ll gcd(ll x, ll y){return (ll)(__gcd(x, y));}
ll lcm(ll x, ll y){return (ll)((x * y) / gcd(x, y));}
ll mod_expo(ll x, ll y, ll p){  
    ll res = 1;
    if((x + p) % p == 0){
        return res = 0;
    }
    x = (x + p) % p;
    while (y > 0){   
        if (y & 1) res = (res*x + p) % p; 
        y = y>>1; x = (x*x + p) % p;  
    }  
    return res;    
}
void usaco(string str = ""){   
    fastio;
    if(str.size()) {
        freopen((str + ".in").c_str(), "r", stdin); 
        freopen((str + ".out").c_str(), "w", stdout);
    }
}
// GFG orz (and the blessings of nishuz sir)
ll getSum(ll BITree[], ll index){
    ll sum = 0;
    while (index > 0){
        sum += BITree[index]; index -= index & (-index);
    }
    return sum;
}
void updateBIT(ll BITree[], ll n, ll index, ll val){
    while (index <= n){BITree[index] += val; index += index & (-index);}
}
void convert(ll arr[], ll n){
    ll temp[n]; for(ll i=0;i<n;i++) temp[i] = arr[i];
    sort(temp, temp+n);
    for (ll i=0;i<n;i++){
        arr[i] = lower_bound(temp, temp+n, arr[i]) - temp + 1;
    }
}
ll getInvCount(ll arr[], ll n){
    ll invcount=0, BIT[n+1];; 
    convert(arr, n);
    for (ll i=1;i<=n;i++) BIT[i] = 0;
    for (ll i=n-1;i>=0;i--){
        invcount += getSum(BIT, arr[i]-1); updateBIT(BIT, n, arr[i], 1);
    }
    return invcount;
}
int main(){      
    usaco();
    ll n; cin >> n; ll a[n], dp[n], temp[n]; 
    for(ll i=0;i<n;i++){cin >> a[i]; temp[i] = a[i];} 
    dp[0] = getInvCount(temp, n); 
    for(ll i=1;i<n;i++){
        dp[i] = dp[i-1] - 2 * a[i-1] + n - 1; 
    }
    for(ll i=0;i<n;i++) cout << dp[i] << "\n";
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rrep(i,n) for(ll i=n-1; i>=0; i--)
#define fi first
#define se second
#define pcnt __builtin_popcountll
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
string zero_padding(int val, int nf){ ostringstream sout;sout << setfill('0') << setw(nf) << val; return sout.str();};
const ld eps = 1e-10;
ull mo = 1000000007;
ld PI=asin(1)*2;
//using namespace atcoder;

int main(){ 
    ll N;
    cin >> N;
    vector<ll> A(N),S(N+1);
    rep(i,N) cin >> A[i];
    rep(i,N){
        if(i%2) A[i] = -A[i];
    }
    rep(i,N){
        S[i+1] = S[i] + A[i];
    }
    map<ll,ll> mp;
    rep(i,N+1) mp[S[i]]++;
    ll ans = 0;
    for(auto& p:mp){
        ll n = p.se;
        ans += n*(n-1)/2;
    }
    cout << ans << endl;
}
