#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mpp;
int main() {
  int t = 1;
  while (t--) {
    long long a = 0, b = 0, x = 0, n, m, d, j, z, nn, mm, aa, bb, y, i, p = 0,
              f = 0, c = 0, cc = 0, pp = 0, l = 0, r = 0, res = 0, k, ans,
              ff = 0;
    cin >> n;
    long long ar[n + 2];
    for (int i = 0; i < n; i++) cin >> ar[i];
    for (int i = 0; i < n; i++) {
      x += ar[i];
      if (x == 0 || mpp[x] > 0) {
        x = 0, c++, i--;
        mpp.clear();
      } else
        mpp[x] = 1;
    }
    cout << c << "\n";
    mpp.clear();
  }
  return 0;
}
