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

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    while (scanf("%d", &n) == 1) {
        vector<int> a(n, 1);
        for (auto &x : a) scanf("%d", &x);

        map<long long, int> m = { { 0, 1 } };
        long long s[2] = { 0 } ;
        long long res = 0;
        for (int i = 0; i < n; i++) {
            s[i % 2] += a[i];
            res += m[s[0] - s[1]]; 
            m[s[0] - s[1]]++;
        }
        printf("%lld\n", res);
    }
}

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector<ll> d_even(n), d_odd(n);
  d_even[0] = a[0];
  d_odd[0] = -a[0];
  FOR(i, 1, n) {
    d_even[i] = a[i] * (i & 1 ? -1 : 1) + d_even[i - 1];
    d_odd[i] = a[i] * (i & 1 ? 1 : -1) + d_odd[i - 1];
  }
  // REP(i, n) cout << d_even[i] << " \n"[i + 1 == n];
  // REP(i, n) cout << d_odd[i] << " \n"[i + 1 == n];
  map<ll, int> mp_even, mp_odd;
  REP(i, n) ++mp_even[d_even[i]];
  REP(i, n) ++mp_odd[d_odd[i]];
  ll ans = 0, cur_even = 0, cur_odd = 0;
  REP(i, n) {
    --mp_even[d_even[i]];
    --mp_odd[d_odd[i]];
    ans += (i & 1 ? mp_odd[cur_odd] : mp_even[cur_even]);
    cur_even += a[i] * (i & 1 ? -1 : 1);
    cur_odd += a[i] * (i & 1 ? 1 : -1);
  }
  cout << ans << '\n';
  return 0;
}
