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