#include <bits/stdc++.h>
using namespace std;
unordered_set<long long int> sum_set({});
int main() {
  int n = 0;
  int num = 0;
  int cnt = 0;
  long long int sum = 0;
  scanf("%d", &n);
  sum_set.clear();
  sum_set.insert(0);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &num);
    sum += num;
    if (sum_set.find(sum) != sum_set.end())
      ++cnt;
    else
      sum_set.insert(sum);
  }
  printf("%d\n", cnt);
  return 0;
}
