#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 54;
const long long INF = 1e18;
const long long M = 1e5 + 5;
const long long mod = 1e9 + 7;
long long a[N], n, m, x, y, z, d, ans, cnt, sum[N], l, r, id, k, f[N][4];
long long dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
double h, h1;
long long g[2222][2222];
char ch;
string s;
vector<long long> ve;
vector<long long> ve1;
map<long long, long long> mp;
map<long long, long long> mp1;
set<long long> se;
deque<long long> de;
priority_queue<long long> Q;
void solve() {
  long long c0 = 0, c1 = 0, mx = -INF, mi = INF, ans1 = 0, q, f1 = 0, f2 = 0;
  ans = 0;
  ve.clear();
  cin >> n;
  mp[0] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    f1 += x;
    if (mp[f1] == 1) {
      ans++;
      f1 = x;
      mp.clear();
      mp[0] = 1;
    }
    mp[f1]++;
  }
  cout << ans << '\n';
}
int main() {
  solve();
  return 0;
}
