#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<ll> vec(n);
  for (auto &v : vec) cin >> v;
  partial_sum(vec.begin(), vec.end(), vec.begin());
  ll ans = 0;
  multiset<ll> st = {0};
  for (auto &v : vec) {
    ll tmp = st.count(v);
    if (tmp != 0) ans += tmp;
    st.insert(v);
  }
  cout << ans << endl;
}
