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