#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9 + 7;
void cioacc() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main() {
  int n;
  cin >> n;
  vl a(n), sum(n + 1, 0);
  multiset<ll> st;
  st.insert(0);
  ll ans = 0;
  for (ll i = (0); i < (ll)(n); ++i) {
    cin >> a.at(i);
    sum.at(i + 1) = sum.at(i) + a.at(i);
    ans += st.count(sum.at(i + 1));
    st.insert(sum.at(i + 1));
  }
  cout << ans << endl;
}
