#include <bits/stdc++.h>
using namespace std;
int factorial(int n) {
  if (n == 0) return 1;
  return n * factorial(n - 1);
}
int combination(int n, int r, bool permutation) {
  if (n <= 1) return n;
  int p = factorial(n) / factorial(n - r);
  int res = p;
  if (!permutation) {
    res /= factorial(r);
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  map<int, int> m;
  vector<int> b(n + 1);
  b[0] = 0;
  m[0]++;
  for (int i = 0; i < n; i++) {
    b[i + 1] = b[i] + a[i];
    m[b[i + 1]]++;
  }
  int cnt = 0;
  for (auto it : m) {
    if (it.second % 2 == 0) {
      cnt += combination(it.second, 2, false);
    }
  }
  cout << cnt << endl;
}
