#include <bits/stdc++.h>
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
const long long N = 200005;
const long long mod = 1000000007;
using namespace std;
void file() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
void zuka() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  zuka();
  int n;
  cin >> n;
  set<long long> temp;
  temp.insert(0);
  long long ans = 0;
  long long current = 0;
  for (int i = 1; i <= n; i++) {
    long long in;
    cin >> in;
    current += in;
    if (temp.count(current)) {
      temp.clear();
      temp.insert(0);
      current = in;
      ans++;
    }
    temp.insert(current);
  }
  cout << ans;
}
