#include <bits/stdc++.h>
std::multiset<long long> S;
int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0, s = 0;
  for (int i = 0, x; i < n; ++i) {
    S.insert(s);
    scanf("%d", &x);
    ans += S.count(s += x);
  }
  printf("%lld\n", ans);
}
