/*
    author : aryan57
    created : 16-May-2021 18:55:19 IST
*/
#include <bits/stdc++.h>
using namespace std;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

#define int long long
#define X first
#define Y second
#define pb push_back
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
#define F(i, a, b) for (int i = a; i <= b; i++)
#define RF(i, a, b) for (int i = a; i >= b; i--)

const int mxn = 1e5;
const long long INF = 2e18;
const int32_t M = 1000000007;
// const int32_t M = 998244353;
const long double pie = acos(-1);

int same(vector <int> &a,vector <int> &b)
{
    map<int,int> mp;

    mp[0]=1;
    int pa=0;
    int pb=0;
    for(int i=0;i<min(sz(a),sz(b));i++)
    {
        pa+=a[i];
        pb+=b[i];
        mp[pa-pb]++;
    }

    int cnt=0;

    for(pair <int,int> p : mp)
    {
        int num=p.Y;

        cnt+=(num)*(num-1)/2;
    }

    return cnt;
}
int other(vector <int> &a,vector <int> &b)
{
    map<int,int> mp1;
    int n=min(sz(a),sz(b));
    vector <int> pa(n+1);
    vector <int> pb(n+1);
    mp1[0]=1;
    for(int i=1;i<=n;i++)
    {
        pa[i]=pa[i-1]+a[i-1];
        pb[i]=pb[i-1]+b[i-1];
        mp1[pa[i]-pb[i]]++;
    }
    mp1[pa[n]-pb[n]]--;
    int cnt=0;
    // dbg(a);
    // dbg(b);
    // dbg(mp1);

    if(sz(a)>sz(b))
    {
        int dif=pa[n]+a[n]-pb[n];
        // dbg(dif,n,a[n],pa[n],pb[n]);
        cnt+=mp1[dif];
    }

    for(int i=n;i>=2;i--)
    {
        mp1[pa[i-1]-pb[i-1]]--;
        int dif=pa[i]-pb[i-1];

        // dbg(i,dif);
        // dbg(mp1);

        cnt+=mp1[dif];
    }

    // dbg(cnt);

    return cnt;
}

void solve_LOG()
{
    int n;
    cin>>n;

    vector <int> a(n);
    vector <int> v1e,v1o;
    vector <int> v2e,v2o;
    F(i,0,n-1)
    {
        cin>>a[i];
    }

    for(int i=0;i<n;i+=1)
    {
        if(i%2)v1o.push_back(a[i]);
        else v1e.push_back(a[i]);
    }
    for(int i=1;i<n;i+=1)
    {
        if(i%2)v2e.push_back(a[i]);
        else v2o.push_back(a[i]);
    }

    int cnt=0;

    cnt+=same(v1e,v1o);
    cnt+=same(v2e,v2o);
    // dbg(cnt);
    cnt+=other(v1e,v1o);
    cnt+=other(v2e,v2o);

    cout<<cnt;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
#endif
#ifdef ARYAN_SIEVE
    sieve();
#endif
#ifdef ARYAN_SEG_SIEVE
    segmented_sieve();
#endif
#ifdef ARYAN_FACT
    fact_init();
#endif
    // cout<<fixed<<setprecision(10);
    int _t=1;
    // cin>>_t;
    for (int i=1;i<=_t;i++)
    {
        // cout<<"Case #"<<i<<": ";
        solve_LOG();
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 1000000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    vector<ll> asum(n);
    map<ll,ll> m;
    ll tot = 0;
    REP(i,n) {
        cin >> a[i];
        if (i%2==0) tot+=a[i];
        else tot-=a[i];
        asum[i]=tot+INF;
    }
    REP(i,n) {
        m[asum[i]]++;
    }
    m[INF]++;
    // REP(i,n) cout << asum[i]-INF << " ";
    // cout << endl;
    ll ans = 0;
    for (auto ite=m.begin();ite!=m.end();ite++) {
        ll cnt = ite->second;
        ans += cnt*cnt-cnt;
    }
    cout << ans/2 << endl;
    return 0;
}