#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (ll i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  return os;
}
double c(ll a) { return a * (a - 1) / 2; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, tmp, cnt = 0, l;
  vector<ll> m;
  map<ll, ll> p;
  m.emplace_back(0);
  cin >> n;
  for (ll i = 0; i < (ll)(n); i++) {
    cin >> tmp;
    l = m.back();
    m.emplace_back(l + tmp);
  }
  sort(m.begin(), m.end());
  ll o = -99999999;
  for (ll i = 0; i <= n; ++i) {
    if (m[i] != o) {
      p[m[i]] = 1;
      o = m[i];
    } else {
      ++p[o];
    }
  }
  for (const auto &a : p) {
    if (a.first == 0) {
      cnt += a.second - 1;
      continue;
    }
    if (a.second >= 2) {
      cnt += static_cast<ll>(c(a.second));
    }
  }
  std::cout << cnt << endl;
}
