#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  int ans = 0;
  int sum;
  for (int i = 0; i < N - 1; ++i) {
    sum = A[i];
    if (A[i] == 0) {
      ++ans;
    }
    for (int j = i + 1; j < N; ++j) {
      sum += A[j];
      if (sum == 0) {
        ++ans;
      }
    }
  }
  cout << ans << endl;
}
