#include <bits/stdc++.h>
using namespace std;
inline int Count(vector<long long> a, int x) {
  int l = -1;
  int r = a.size();
  while (r - l > 1) {
    int m = (l + r) >> 1;
    if (a[m] < x) {
      l = m;
    } else {
      r = m;
    }
  }
  int ll = r;
  l = -1;
  r = a.size();
  while (r - l > 1) {
    int m = (l + r) >> 1;
    if (a[m] <= x) {
      l = m;
    } else {
      r = m;
    }
  }
  return r - ll;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<long long> sum(n);
  scanf("%lld", &sum[0]);
  long long x;
  long long ans = 0ll;
  if (sum[0] == 0ll) {
    ++ans;
  }
  for (int i = 1; i < n; i++) {
    scanf("%lld", &x);
    sum[i] = sum[i - 1] + x;
    if (sum[i] == 0ll) {
      ++ans;
    }
  }
  sort(sum.begin(), sum.end());
  int ind = 0;
  while (ind < sum.size()) {
    int x = Count(sum, sum[ind]);
    ans += (long long)(x * (x - 1ll)) >> 1;
    ind += x;
  }
  printf("%lld", ans);
  return 0;
}
