#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &v : a) cin >> v;
  for (int i = 0; i < n - 1; i++) a[i + 1] += a[i];
  sort(a.begin(), a.end());
  long long cnt = 0;
  if (a[0] == 0 && n == 1) cnt++;
  for (int i = 0; i < n - 1; i++) {
    long long x = 1;
    if (a[i] == 0) cnt++;
    while (i < n - 1 && a[i] == a[i + 1]) {
      i++;
      x++;
      if (a[i] == 0) cnt++;
    }
    cnt += x * (x - 1) / 2;
  }
  cout << (cnt) << endl;
  return 0;
}
