#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template <typename T>
using V = vector<T>;
template <typename T>
using VV = vector<V<T>>;
template <typename T>
using VVV = vector<VV<T>>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  map<int, ll> cnt;
  cnt[0] = 1;
  ll sum = 0;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    sum += x;
    if (cnt.count(sum)) {
      ans += cnt[sum];
    }
    cnt[sum]++;
  }
  cout << ans << endl;
  return 0;
}
