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