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