#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;
struct aaa {
  aaa() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
ll NumOfSequenceSum(vector<ll>& sequence, ll K) {
  ll N = sequence.size();
  vector<ll> sum(N);
  map<ll, ll> ct;
  ll ans = 0;
  sum[0] = sequence[0];
  ct[sum[0]]++;
  if (sum[0] == K) ans++;
  for (int i = 1; i < N; i++) {
    sum[i] = sum[i - 1] + sequence[i];
    if (sum[i] == K) ans++;
    if (sum[i] >= K) ans += ct[sum[i] - K];
    ct[sum[i]]++;
  }
  return ans;
}
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < (N); ++i) cin >> A[i];
  cout << (NumOfSequenceSum(A, 0)) << '\n';
  return 0;
}
