#include <bits/stdc++.h>
int main() {
  int N;
  int A[400000];
  int sum[400000];
  int cnt = 0;
  scanf("%d", &N);
  scanf(" %d", &A[0]);
  sum[0] = A[0];
  for (int n = 1; n < N; n++) {
    scanf(" %d", &A[n]);
    sum[n] = sum[n - 1] + A[n];
  }
  for (int n = 0; n < N; n++)
    if (sum[n] == 0) cnt++;
  for (int m = 0; m < N; m++)
    for (int n = m + 1; n < N; n++)
      if (sum[n] == sum[m]) cnt++;
  printf("%d\n", cnt++);
}
