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

const int maxn = 2e5+8, inf  = 1e18+9, mod  = 998244353;

int n, m;

void solve() {
    int i, j, ans = 0, pre = 0;
    map<int, int> mp; mp[pre]++;
    cin >> n;
    for (i = 1; i <= n; i++) {
        int v; cin >> v;
        if (i & 1) pre -= v;
        else pre += v;
        ans += mp[pre]++;
    }
    cout << ans << endl;
}

signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); //cout << fixed << setprecision(15);
    int t = 1; //cin >> t;
    while (t--) solve();
    return 0;
}


/*
problem :
algorithm :
created : Programmer_juruo
*/

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

#define int long long
#define N 2000005
#define M 2005
#define lowbit(x) x & (-x)
#define F1(i, n) for(int i = 1; i <= n; i++)
#define F(i, a, n) for(int i = a; i <= n; i++)
#define F0(i, n) for(int i = 0; i < n; i++)
#define dbg(x) cout << #x << ":" << x << endl;
#define se second
#define fi first
#define y1 juruo
#define mp make_pair
#define pb push_back
#define arr vector<int>
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

typedef pair <int, int> pii;
typedef priority_queue <int> pq;
typedef long long ll;

const int inf = 0x3f3f3f3f;
const int p = 107;
const int P = 100007;
const int Mod = 1e9+7;

int n, m;

int S[N];
map<int, int> Map;
int Ans = 0;

void Go(int x) {
	Ans += Map[x];
	++Map[x];
}

void work() {
	cin >> n;
	for(int i = 3; i <= n+2; i++) cin >> S[i];
	for(int i = 5; i <= n+2; i++) {
		S[i] += S[i-2];
	}
	n += 2;
	for(int i = 2; i <= n; i += 2) {
		Go(S[i] - S[i-1]);
		if(i+1 <= n) Go(S[i] - S[i+1]); 
	}
	
	cout << Ans << endl;
}

signed main() {
  //freopen("1.in", "r", stdin);
  //freopen("1.out", "w", stdout);
  int T = 1;

  //cin >> T;

  while(T--) {
  	work();
  }

  return 0;
}

