#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
const ll mod = 1000000007;
const int M_MAX = 10000;
string al = "abcdefghijklmnopqrstuvwxyz";
int n, k;
int tri[100001];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  int right = 0, left = 0, sum = 0, cnt = 0;
  int pos = 0;
  while (left != n - 1) {
    sum += v[right];
    if (right == n - 1) {
      left = pos++;
      right = left;
      sum = 0;
      continue;
    }
    if (sum == 0) {
      cnt++;
      right++;
    } else {
      right++;
    }
  }
  cout << cnt << endl;
  return 0;
}
