#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vl = vector<ll>;
using vvl = vector<vl>;
const ll MOD = 1e9 + 7;
void cioacc() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main() {
  cioacc();
  ll n;
  cin >> n;
  vl sum(1, 0);
  unordered_multiset<ll> st;
  st.insert(0);
  ll ans = 0;
  for (ll i = (0); i < (ll)(n); ++i) {
    ll tmp;
    cin >> tmp;
    sum.emplace_back(sum.back() + tmp);
    ans += st.count(sum[i + 1]);
    st.insert(sum[i + 1]);
  }
  cout << ans << endl;
}
