#include <bits/stdc++.h>
int compare(const void *p, const void *q) { return *(int *)p - *(int *)q; }
int main() {
  long long n, i, j, count = 0;
  scanf("%lld", &n);
  long long row[n], sum[n + 1];
  sum[0] = 0;
  for (i = 0; i < n; i++) {
    scanf("%lld", &row[i]);
    sum[i + 1] = sum[i] + row[i];
  }
  qsort(sum, n + 1, sizeof(long long), compare);
  for (i = 1; i < n + 1; i++) {
    for (j = i - 1; j > -1; j--) {
      if (sum[i] == sum[j])
        count += 1;
      else
        break;
    }
  }
  printf("%d", count);
}
