#include <bits/stdc++.h>
using namespace std;
long long int sum[100005], say, x, y, z, ans, last;
int main() {
  scanf("%lld", &x);
  for (int i = 1; i <= x; i++) {
    scanf("%lld", &sum[i]);
    sum[i] += sum[i - 1];
  }
  sort(sum + 1, sum + 1 + x);
  for (int i = 1; i <= x; i++) {
    if (sum[i] == 0) {
      ans++;
      say = 0;
      last = 999999999;
      continue;
    }
    if (sum[i] == last) {
      say++;
    } else {
      say++;
      ans += say - 1;
      say = 0;
    }
    last = sum[i];
  }
  say++;
  ans += say - 1;
  printf("%lld", ans);
}
