#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void cioacc() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main() {
  cioacc();
  ll n;
  cin >> n;
  multiset<ll> st;
  st.insert(0);
  ll ans = 0;
  ll last = 0;
  ll now;
  for (ll i = (0); i < (ll)(n); ++i) {
    cin >> now;
    now += last;
    ans += st.count(now);
    st.insert(now);
    last = now;
  }
  cout << ans << endl;
}
