#include <bits/stdc++.h>
int main(void) {
  long int n;
  scanf("%ld", &n);
  long int a[n], i, sum[n], ans = 0, max;
  for (i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
    if (i == 0)
      max = a[i];
    else if (max < a[i])
      max = a[i];
  }
  long int cnt[100000001] = {0};
  sum[0] = a[0];
  for (i = 1; i < n; i++) {
    sum[i] = sum[i - 1] + a[i];
  }
  for (i = 0; i < n; i++) {
    if (cnt[sum[i]] == 0)
      cnt[sum[i]] = 1;
    else
      cnt[sum[i]]++;
    if (sum[i] == 0) ans++;
    if (cnt[sum[i]] > 1) ans = ans + cnt[sum[i]] - 1;
  }
  printf("%ld\n", ans);
  return 0;
}
