#include <bits/stdc++.h>
int combination(int n, int k) {
  if (n < k) return 0;
  if (k > 0) {
    return combination(n, k - 1) * (n - k + 1) / k;
  } else {
    return 1;
  }
}
int func(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main(void) {
  int N;
  long S[200001];
  long sorted[200001];
  scanf("%d", &N);
  S[0] = 0;
  for (int i = 1; i <= N; i++) {
    long temp;
    scanf("%ld", &temp);
    S[i] = S[i - 1] + temp;
  }
  long max = -10000000;
  for (int i = 1; i <= N; i++) {
    if (max < S[i]) max = S[i];
  }
  qsort(S, N + 1, sizeof(long), func);
  int before = 1;
  int res = 0;
  for (int i = 1; i <= N; i++) {
    if (S[i] == S[i - 1]) {
      before++;
    } else {
      res += combination(before, 2);
      before = 1;
    }
  }
  res += combination(before, 2);
  printf("%d\n", res);
  return 0;
}
