#include <bits/stdc++.h>
double k;
int ck;
int compare_int(const void *a, const void *b) {
  k = *(double *)a - *(double *)b;
  if (k > 0) ck = 1;
  if (k < 0) ck = -1;
  return ck;
}
int main() {
  int n, i, j;
  double a[200002], sum[200002], ans = 0, count;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%lf", &a[i]);
  sum[0] = 0;
  for (i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
  qsort(sum, n + 1, sizeof(double), compare_int);
  count = 1;
  double 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("%lf\n", ans);
  return 0;
}
