#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int p[200001];
  int s[200001];
  map<int, int> index;
  int count = 0;
  int A;
  int sum = 0;
  int before = 0;
  int start = 0;
  for (size_t i = 0; i < N; i++) {
    cin >> A;
    p[i] = A;
    s[i] = 0;
    sum += A;
    if (sum == 0) {
      index[i] = before;
      before = i + 1;
      int j = index[i] - 1;
      s[index[i]] = (start > j) ? 1 : s[index[j]] + 1;
    }
  }
  for (size_t i = 1; i < N; i++) {
    if (s[i]) continue;
    sum = 0;
    before = i;
    start = i;
    for (size_t j = i; j < N; j++) {
      sum += p[j];
      if (sum == 0) {
        index[j] = before;
        before = j + 1;
        int k = index[j] - 1;
        s[index[j]] = (start > k) ? 1 : s[index[k]] + 1;
      }
    }
  }
  for (size_t i = 0; i < N; i++) {
    count += s[i];
  }
  cout << count;
  return 0;
}
