#include <bits/stdc++.h>
using namespace std;
int n;
long long a[200010];
long long ans;
void solve() {
  cin >> n;
  map<long long, long long> mp;
  mp[0]++;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
    mp[a[i]]++;
    if (a[i] == a[i - 1]) {
      ans += max(mp[a[i]] - 2, 0LL);
    } else {
      ans += max(mp[a[i]] - 1, 0LL);
    }
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
