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