#include <bits/stdc++.h>
using ll = long long;
ll N;
ll s;
std::map<ll, ll> mp;
ll factorial(const ll &n) {
  if (n < 2) return 1;
  ll ans = 1;
  for (int i = 2; i <= n; ++i) ans *= i;
  return ans;
}
ll comb(const ll &n, const ll &r) {
  if (n < r) return 0;
  if (n == r) return 1;
  return (factorial(n) / factorial(r)) / factorial(n - r);
}
void solve() {
  ll ans = 0;
  std::map<ll, ll>::iterator itr = mp.begin();
  while (itr != mp.end()) {
    ans += comb(itr->second, (ll)2);
    ++itr;
  }
  std::cout << ans << std::endl;
}
int main() {
  std::cin >> N;
  ++mp[0];
  for (int i = 0; i < N; ++i) {
    ll a;
    std::cin >> a;
    s += a;
    ++mp[s];
  }
  solve();
  return 0;
}
