#include <bits/stdc++.h>
int main() {
  int n, a[100001u], x[100001u];
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    x[i] = 0;
  }
  for (int i = 1; i <= n; ++i) {
    long long sum = 0;
    for (int j = i; j <= n; ++j) {
      sum += a[j];
      if (sum == 0) {
        x[i] = j;
        break;
      }
    }
  }
  int zeros = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      if (x[j] == 0) break;
      zeros++;
      if (x[x[j]] == 0)
        break;
      else
        j = x[j];
    }
  }
  printf("%d\n", zeros);
  return 0;
}
