#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int MAX = 1e6 + 5;
const long long MAX2 = 11;
const long long MOD = 998244353;
const long long MOD2 = 1000005329;
const long long INF = 2e18;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1, 0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 1000;
long long n, x, y, id, nx[MAX], ans, mn;
vector<int> v[MAX];
map<long long, int> hs;
int main() {
  cout << fixed << setprecision(10);
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  hs[0] = id = 1;
  v[1].push_back(0);
  for (long long i = 1; i <= n; ++i) {
    cin >> x;
    y += x;
    if (!hs.count(y)) hs[y] = ++id;
    v[hs[y]].push_back(i);
  }
  for (long long i = 1; i <= id; ++i) {
    y = v[i].size() - 1;
    for (int j = 0; j < y; ++j) nx[v[i][j] + 1] = v[i][j + 1];
  }
  mn = MOD;
  for (long long i = 0; i <= n; ++i) {
    if (i == mn) ++ans, mn = MOD;
    if (nx[i]) mn = min(mn, nx[i]);
  }
  if (mn != MOD) ++ans;
  cout << ans << '\n';
  return 0;
}
