#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<ll> dp(n + 1, 0);
  for (int i = 0; i < (n); ++i) {
    ll t;
    cin >> t;
    dp[i + 1] = dp[i] + t;
  }
  ll cnt = 0;
  multiset<ll> mp;
  mp.insert(0);
  for (int i = (n - 1); i >= 0; --i) {
    cnt += mp.count(dp[i]);
    mp.insert(dp[i]);
  }
  cout << cnt - 1 << endl;
  return 0;
}
