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