#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N), S(N);
  for (ll i = 0; i < (ll)(N); i++) {
    cin >> A.at(i);
    if (i == 0)
      S.at(i) = A.at(i);
    else
      S.at(i) = S.at(i - 1) + A.at(i);
  }
  sort(S.begin(), S.end());
  map<int, int> m;
  for (ll i = 0; i < (ll)(N); i++) {
    if (m.count(S.at(i)))
      m[S.at(i)]++;
    else
      m[S.at(i)] = 1;
  }
  ll res = 0;
  for (auto p : m) {
    ll s = p.first;
    ll num = p.second;
    if (s == 0) num++;
    if (num < 2) continue;
    res += num * (num - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
