#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
inline int read() {
  int sum = 0, fh = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') fh = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum * fh;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
set<long long> a;
int main() {
  int n, ans = 0;
  long long qz = 0;
  cin >> n;
  a.insert(0);
  for (int i = 1; i <= n; ++i) {
    long long x = read();
    qz += x;
    if (a.count(qz)) {
      a.clear();
      qz = x;
      a.insert(0);
      ans += 1;
    }
    a.insert(qz);
  }
  cout << ans;
}
