#include <bits/stdc++.h>
int compare_int(const void *a, const void *b) {
  return *(long *)a - *(long *)b;
}
int main() {
  int n, i, j, check[200001], count;
  long a[200001], sum[200002], ans = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%ld", &a[i]);
  sum[0] = 0;
  for (i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
  qsort(sum, n + 1, sizeof(long), compare_int);
  count = 1;
  long memory = 0;
  for (i = 1; i <= n; i++) {
    if (sum[i] == memory)
      count++;
    else {
      if (count > 1) ans += count * (count - 1) / 2;
      count = 1;
      memory = sum[i];
    }
  }
  if (count > 1) ans += count * (count - 1) / 2;
  printf("%ld\n", ans);
  return 0;
}
