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