#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  int a[1000001];
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  int sa[1000001];
  sa[0] = 0;
  for (long long i = 0; i < n; i++) {
    sa[i + 1] = sa[i] + a[i];
  }
  sort(sa, sa + n + 1);
  long long ans = 0;
  map<int, int> mp;
  for (long long i = 0; i <= n + 1; i++) {
    if (mp.count(sa[i]) == 0)
      mp[a[i]]++;
    else
      ans++;
  }
  cout << ans << endl;
}
