#include <bits/stdc++.h>
int comp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main(void) {
  int n;
  scanf("%d", &n);
  long a[n];
  for (int i = 0; i < n; i++) scanf("%ld", &a[i]);
  long long cus[n + 1];
  cus[0] = 0;
  for (int i = 0; i < n; i++) cus[i + 1] = cus[i] + a[i];
  qsort(cus, n + 1, sizeof(long long), comp);
  long long now = cus[0];
  int cnt = 1;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (cus[i] == now)
      cnt++;
    else {
      if (cnt >= 2) ans += (cnt * (cnt - 1)) / 2;
      now = cus[i];
      cnt = 1;
    }
  }
  if (cnt >= 2) ans += (cnt * (cnt - 1)) / 2;
  printf("%d", ans);
  return 0;
}
