#include <bits/stdc++.h>
using namespace std;
set<long long> pref;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, rez = 0;
  cin >> N;
  long long p = 0;
  pref.insert(0);
  for (int i = 1; i <= N; i++) {
    long long a;
    cin >> a;
    p += a;
    if (pref.find(p) != pref.end()) {
      rez++;
      pref.clear();
      pref.insert(0);
      p = a;
    }
    pref.insert(p);
  }
  cout << rez;
  return 0;
}
