#include <bits/stdc++.h>
int dc = 100000;
int comp(const void* a, const void* b) {
  long int x = *((long int*)a), y = *((long int*)b);
  return x - y;
}
int main() {
  if (0) printf("*** debug mode ***\n");
  int n;
  scanf("%d", &n);
  long int a[n], s[n + 1], i;
  s[0] = 0;
  for (i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
    s[i + 1] = a[i] + s[i];
  }
  qsort(s, n + 1, sizeof(long int), comp);
  long int sum = 0;
  long int count = 0, temp = s[0] - 1;
  for (i = 0; i < n + 1; i++) {
    if (temp == s[i]) {
      count++;
      continue;
    }
    sum += count * (count - 1) / 2;
    temp = s[i];
    count = 1;
  }
  sum += count * (count - 1) / 2;
  printf("%ld", sum);
  return 0;
}
