#include <bits/stdc++.h>
using namespace std;
int n;
int main(int, char**) {
  std::ios::sync_with_stdio(false);
  cin >> n;
  long long int res = 0;
  long long int s = 0;
  unordered_set<long long int> ss;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    s += x;
    if (s == 0 || ss.count(s) != 0) {
      ++res;
    }
    ss.insert(s);
  }
  cout << res << endl;
  return 0;
}
