#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
long long sum[maxn];
map<long long, long long> mp;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0)
      sum[i] = a[i];
    else
      sum[i] = sum[i - 1] + a[i];
  }
  for (int i = 0; i < n; i++) {
    mp[sum[i]]++;
  }
  long long ans = 0;
  map<long long, long long>::iterator it = mp.begin();
  while (it != mp.end()) {
    if (it->second > 1) {
      ans += (it->second) * (it->second - 1) / 2;
    }
    if (it->first == 0) ans += it->second;
    it++;
  }
  cout << ans << endl;
  return 0;
}
