#include <bits/stdc++.h>
int sort_cmp(const void *a, const void *b) {
  return *(long long int *)a - *(long long int *)b;
}
int main() {
  int n;
  long long int *s, tmp;
  int i, j, cnt;
  scanf("%d", &n);
  s = (long long int *)calloc(sizeof(long long int), n + 1);
  s[0] = 0;
  for (i = 0; i < n; i++) {
    scanf("%lld", &tmp);
    s[i + 1] = s[i] + tmp;
  }
  qsort(s, n + 1, sizeof(long long int), sort_cmp);
  for (i = 0, cnt = 0; i < n; i++) {
    for (j = 1; i < n; i++) {
      if (s[i + 1] == s[i]) {
        j++;
        continue;
      }
      break;
    }
    cnt += j * (j - 1) / 2;
  }
  free(s);
  printf("%d\n", cnt);
  return 0;
}
