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