#include <bits/stdc++.h>
using namespace std;
long long n, k, a[100005];
map<long long, long long> mp;
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  long long ans = 0, s = 0;
  for (long long i = 1; i <= n; i++) {
    s += a[i];
    if (mp.find(s) == mp.end())
      mp[s] = 1;
    else {
      ans += mp[s];
      mp[s]++;
    }
    if (s == 0) ans++;
  }
  printf("%lld\n", ans);
  return 0;
}
