#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void init();
void solve();
signed main() {
  init();
  solve();
}
vector<ll> sum;
ll N;
void init() {
  cin >> N;
  sum.resize(N + 1);
  sum[0] = 0;
  for (ll i = (ll)(1); i < (ll)(N + 1); i++) {
    cin >> sum[i];
    sum[i] += sum[i - 1];
  }
}
ll culc(ll x) {
  ll y = x;
  return y * (y - 1) / 2;
}
void solve() {
  ll res = 0;
  sort((sum).begin(), (sum).end());
  for (ll i = 0; i < (ll)(N + 1); i++) {
    ll j = i + 1;
    ll t = 1;
    while (sum[i] == sum[j]) {
      t++;
      j++;
    }
    i = j - 1;
    res += culc(t);
  }
  cout << res << endl;
}
