#include<bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define nep(i,r,l) for(int i=r;i>=l;i--)
void sc(int &x){scanf("%d",&x);}
void sc(int &x,int &y){scanf("%d%d",&x,&y);}
void sc(int &x,int &y,int &z){scanf("%d%d%d",&x,&y,&z);}
void sc(ll &x){scanf("%lld",&x);}
void sc(ll &x,ll &y){scanf("%lld%lld",&x,&y);}
void sc(ll &x,ll &y,ll &z){scanf("%lld%lld%lld",&x,&y,&z);}
void sc(char *x){scanf("%s",x);}
void sc(char *x,char *y){scanf("%s%s",x,y);}
void sc(char *x,char *y,char *z){scanf("%s%s%s",x,y,z);}
void out(int x){printf("%d\n",x);}
void out(ll x){printf("%lld\n",x);}
void out(int x,int y){printf("%d %d\n",x,y);}
void out(ll x,ll y){printf("%lld %lld\n",x,y);}
void out(int x,int y,int z){printf("%d %d %d\n",x,y,z);}
void out(ll x,ll y,ll z){printf("%lld %lld %lld\n",x,y,z);}
using namespace std;
const int N=3e5+5;
int n;
unordered_map<ll,int>vis;
int main()
{
    //freopen("1.in","r",stdin);freopen("1.out","w",stdout);
    sc(n);
    vis[0]++;
    ll sum=0,ans=0;
    while(n--)
    {
        int x;sc(x);
        if(n&1) sum+=x;
        else sum-=x;
        ans+=vis[sum];
        vis[sum]++;
    }
    out(ans);
}

#include <bits/stdc++.h>
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    i64 n;
    std::cin >> n;
    std::map<i64, int> count;
    count[0]++;
    i64 ans = 0, sum = 0;
    for (int i = 0; i < n; i++) {
        int x;
        std::cin >> x;
        if (i % 2 == 0) {
            sum += x;
        } else {
            sum -= x;
        }
        ans += count[sum]++;
    }
    std::cout << ans << "\n";
    return 0;
}