#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 1;
signed main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) cin >> A[i];
  vector<long long> cum(N, 0);
  cum[0] = A[0];
  map<long long, long long> cnt;
  cnt[0] = 1;
  cnt[A[0]] = 1;
  long long ans = 0;
  if (A[0] == 0) ans++;
  for (long long i = 1; i < N; i++) {
    cum[i] = cum[i - 1] + A[i];
    ans += cnt[cum[i]];
    cnt[cum[i]] += 1;
  }
  cout << ans << endl;
  return 0;
}
