#include <bits/stdc++.h>
using namespace std;
long long num_seq[200005];
int main() {
  int N, idx = 0, count = 0, sum_num;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> num_seq[i];
  while (idx < N) {
    sum_num = 0;
    for (int i = idx; i < N; i++) {
      if (num_seq[i] == 0) {
        idx = i + 1;
        break;
      } else {
        sum_num += num_seq[i];
        if (sum_num == 0) {
          count++;
        } else
          continue;
      }
    }
    idx++;
  }
  cout << count << endl;
  return 0;
}
