#include <bits/stdc++.h>
int upll(const void* a, const void* b) {
  return *(long long*)a < *(long long*)b   ? -1
         : *(long long*)a > *(long long*)b ? 1
                                           : 0;
}
void sortup(long long* a, int n) { qsort(a, n, sizeof(long long), upll); }
long long a[200010];
long long ans;
int main() {
  int n;
  scanf("%d", &n);
  for (long long i = (0); i < (n); i++) scanf("%lld", a + i + 1);
  for (long long i = (1); i < (n + 1); i++) a[i] += a[i - 1];
  sortup(a, n + 1);
  a[n + 1] = -((1LL << 62) - (1LL << 31));
  for (int l = 0; l <= n + 1;) {
    int r = l;
    while (a[l] == a[r]) r++;
    ans += ((r - l - 1) * (r - l - 1 + 1) / 2);
    l = r;
  }
  printf("%lld\n", ans);
  return 0;
}
