#include <bits/stdc++.h>
struct arr {
  long long x;
  int y, t;
} b[100010] = {0};
int a[100010], cnt[100010] = {0}, n, i;
long long ans = 0, s = 0;
int cmp1(const void *a, const void *b) {
  if ((*(arr *)a).x > (*(arr *)b).x)
    return 1;
  else
    return -1;
}
int cmp2(const void *a, const void *b) { return (*(arr *)a).t - (*(arr *)b).t; }
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    b[i].x = b[i - 1].x + (long long)a[i];
    b[i].t = i;
  }
  qsort(b + 1, n, sizeof(b[0]), cmp1);
  b[1].y = 1;
  for (i = 2; i <= n; i++)
    if (b[i].x == b[i - 1].x)
      b[i].y = b[i - 1].y;
    else
      b[i].y = b[i - 1].y + 1;
  qsort(b + 1, n, sizeof(b[0]), cmp2);
  for (i = 1; i <= n; i++) {
    ans += (long long)cnt[b[i].y];
    if (b[i].x == 0LL) ans++;
    cnt[b[i].y]++;
  }
  printf("%lld", ans);
  return 0;
}
