#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int Nmax = 100005;
int gcd(int a, int b) {
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}
bool isPrime(int n) {
  for (int i = 2; i <= sqrt(n); i++)
    if (n % i == 0) return 0;
  return 1;
}
void binaryRepresentation(int x) {
  for (int i = 31; i >= 0; i--) {
    if (x & (1 << i))
      cout << "1";
    else
      cout << "0";
  }
}
bool check(string a, string b) {
  vector<int> first(26, 0);
  vector<int> second(26, 0);
  for (int i = 0; i < a.length(); i++) {
    first[a[i] - 'a']++;
    second[b[i] - 'a']++;
  }
  int x = accumulate(first.begin(), first.end(), 0);
  int y = accumulate(second.begin(), second.end(), 0);
  if (x != y)
    return false;
  else
    return true;
}
int combination(int n, int r) {
  if (r == n || r == 0) {
    return 1;
  }
  return combination(n - 1, r - 1) + combination(n - 1, r);
}
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.second == b.second) return a.first < b.first;
  return a.second > b.second;
}
int main() {
  long long n;
  cin >> n;
  vector<long long> ar(n);
  for (long long i = 0; i < n; i++) {
    cin >> ar[i];
  }
  set<long long> s;
  s.insert(0);
  long long cur = 0;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    cur += ar[i];
    if (s.find(cur) != s.end()) {
      ++ans;
      s.clear();
      s.insert(0);
      cur = ar[i];
    }
    s.insert(cur);
  }
  cout << ans;
  return 0;
}
