#include <bits/stdc++.h>
using namespace std;
int result = 0;
int search(int[], int, int);
int main() {
  int a[200000];
  int num, r;
  cin >> num;
  for (int i = 0; i < num; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < num; i++) {
    r = search(a, num, i);
    while (r != 0 && r < num) {
      r = search(a, num, r);
    }
  }
  cout << result << endl;
}
int search(int a[], int num, int start) {
  int sum = 0;
  for (int i = start; i < num; i++) {
    sum += a[i];
    if (sum == 0) {
      result++;
      return (i + 1);
    }
  }
  return 0;
}
