#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  ll a[n];
  for (ll i = 0; i < n; ++i) cin >> a[i];
  map<ll, ll> cnt;
  ll ans = 0;
  ll sum[n];
  sum[0] = a[0];
  cnt[sum[0]] = 0;
  if (sum[0] == 0) {
    ans++;
    cnt[sum[0]]++;
  }
  for (ll i = 1; i < n; ++i) {
    sum[i] = sum[i - 1] + a[i];
    if (sum[i] == 0) ans++;
    if (cnt.find(sum[i]) != cnt.end()) {
      cnt[sum[i]]++;
      ans += cnt[sum[i]];
    } else {
      cnt[sum[i]] = 0;
    }
  }
  cout << ans << endl;
}
