#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc) {
  o << "sz = " << vc.size() << endl << "[";
  for (const T& v : vc) o << v << ",";
  o << "]";
  return o;
}
using ll = long long;
int main() {
  int N;
  cin >> N;
  ll s = 0;
  map<ll, int> cnt;
  cnt[0]++;
  for (int i = 0; i < (int)(N); i++) {
    ll a;
    cin >> a;
    s += a;
    cnt[s]++;
  }
  ll ans = 0;
  for (auto it : cnt) {
    ans += it.second * (it.second - 1) / 2;
  }
  cout << ans << endl;
}
