#include <bits/stdc++.h>
long long a[20010];
int n;
std::map<int, int> s;
int main() {
  scanf("%d", &n);
  s[0] = 1;
  int cnt = 0;
  scanf("%d", &a[0]);
  if (s[a[0]] != 0) {
    cnt += s[a[0]];
  }
  s[a[0]]++;
  for (int i = 1; i < n; i++) {
    scanf("%lld", &a[i]);
    a[i] = a[i] + a[i - 1];
    if (s[a[i]] != 0) {
      cnt += s[a[i]];
    }
    s[a[i]]++;
  }
  printf("%d\n", cnt);
  return 0;
}
