#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int *v = new int[n + 1];
  v[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    cin >> v[i];
    v[i] += v[i - 1];
    printf((char *)"read val");
    printf("\n");
    ;
  }
  sort(v, v + n);
  printf((char *)v);
  printf("\n");
  ;
  int cnt = 0;
  int uniq = v[0];
  for (int i = 1; i < n + 1; i++) {
    if (uniq == v[i]) {
      cnt++;
    } else {
      uniq = v[i];
    }
  }
  cout << cnt;
  delete (v);
  return 0;
}
