#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, res = 0, c = 0;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int s = 0; s < N - 1; s++) {
    c = A[s];
    if (c == 0) {
      continue;
    }
    for (int e = s + 1; e < N; e++) {
      if (A[e] == 0) {
        break;
      }
      c += A[e];
      if (c == 0) res++;
    }
  }
  cout << res << endl;
}
