#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  ll N, ans = 0, temp;
  cin >> N;
  vector<ll> A(N), sum(N);
  for (int i = 0; i < (N); i++) {
    cin >> A[i];
  }
  sum[0] = A[0];
  for (int i = 1; i < N; i++) {
    sum[i] = sum[i - 1] + A[i];
  }
  sort(sum.begin(), sum.end());
  for (int i = 0; i < (N); i++) {
    if (sum[i] == 0) {
      ans++;
    }
    if (sum[i] > 0) {
      break;
    }
  }
  for (int i = temp; i < N - 1; i++) {
    if (sum[i] == sum[i + 1]) ans++;
  }
  cout << ans << endl;
  return 0;
}
