#include <bits/stdc++.h>
int cmp(const void *, const void *);
long long arr[200005] = {};
int main() {
  long long n;
  long long ans = 0;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &arr[i]);
    arr[i] = arr[i] + arr[i - 1];
  }
  qsort(arr, n + 1, sizeof(long long), cmp);
  long long cnt = 0;
  for (long long i = 0; i <= n; i++) {
    cnt++;
    if (arr[i + 1] != arr[i]) {
      ans = ans + ((cnt) > 1 ? ((cnt) * ((cnt)-1)) / 2 : 0);
      cnt = 0;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
int cmp(const void *x, const void *y) {
  if (*(long long *)x > *(long long *)y) {
    return 1;
  } else if (*(long long *)x == *(long long *)y) {
    return 0;
  } else {
    return -1;
  }
}
