#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 = 0;
  int past = S[0];
  long long ans = 0;
  for (int i = 0; i <= N; i++) {
    if (S[i] == past && i != N) {
      cnt++;
    } else {
      if (i == N && S[i] == past) cnt++;
      if (cnt % 2 == 0)
        ans += cnt / 2 * (cnt - 1);
      else
        ans += (cnt - 1) / 2 * cnt;
      past = S[i];
      cnt = 1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
