#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main() {
  ll N;
  cin >> N;
  ll a[N];
  vector<ll> b(N + 1);
  b[0] = 0;
  for (ll i = 0; i < N; i++) {
    cin >> a[i];
    b[i + 1] = b[i] + a[i];
  }
  sort(b.begin(), b.end());
  ll ans = 0;
  ll temp = 1;
  for (ll i = 0; i < N + 1; i++) {
    if (b[i] == b[i + 1]) {
      temp++;
    } else {
      ans += temp * (temp - 1) / 2;
      temp = 1;
    }
  }
  cout << ans << endl;
  return 0;
}
