#include <bits/stdc++.h>
typedef long long i64;
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define per(i, a, b) for (int i = (b) - 1; i >= (a); --i)
using namespace std;

int main() {
  // freopen("#.in", "r", stdin); // @
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  i64 sum = 0;
  vector<i64> a;
  rep(r, 0, n + 1) {
    a.push_back(sum);
    if (r == n) {break;}
    int x; cin >> x; r & 1 ? sum += x : sum -= x;
  }
  sort(all(a));
  i64 res = 0;
  for (int l = 0, r = 0; l < sz(a); l = r) {
    for (; r < sz(a) and a[r] == a[l]; ++r);
    res += 1ll * (r - l) * (r - l - 1) / 2;
  }
  cout << res << '\n';
  return 0;
}

/* 📌https://www.cnblogs.com/George1123/p/tips.html */
#include <bits/stdc++.h>
using namespace std;

unordered_map <long long, int> mp;

int main() {
	int n; scanf("%d", &n);
	long long sum = 0, ans = 0;
	mp[0] = 1;
	for (int i = 0; i < n; ++i) {
		int x; scanf("%d", &x);
		if (i & 1)
			sum -= x;
		else
			sum += x;
		ans += mp[sum]++;
	}
	printf("%lld\n", ans);
	return 0;
}

