#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a, mid;
  a.resize(N);
  mid.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int result = 0;
  for (int i = 0; i != 1; i++) {
    int checker = 0;
    for (int j = 0; j < N; j++) {
      checker += a[i + j];
      mid[j] = checker;
      if (checker == 0) result++;
    }
  }
  for (int j = 0; j < N - 1; j++) {
    for (int i = 0; i < N - j; i++) {
      mid[N - i - 1] = mid[N - i - 1] - a[i];
      if (mid[i] == 0) result++;
    }
  }
  cout << result << endl;
  return 0;
}
