#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  long N;
  cin >> N;
  vector<long> As(N);
  for (long i = 0; i < N; i++) {
    cin >> As[i];
  }
  long ans = 0;
  for (long i = 1; i <= N; i++) {
    long sum = std::accumulate(As.begin(), As.begin() + i, 0);
    if (sum == 0) ans++;
    for (long j = 1; j <= N - i; j++) {
      sum -= As[j - 1];
      sum += As[i + j - 1];
      if (sum == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
