#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  scanf("%d", &N);
  vector<long long int> A(N);
  long long int all = 0;
  for (int i = 0; i < N; i++) {
    scanf("%lld", &(A[i]));
    all += A[i];
  }
  int sum;
  long long int ans = 0;
  for (int i = 0; i < N - i - 1; i++) {
    sum = 0;
    if (all == 0) {
      ans++;
    }
    for (int j = i; j < N - i - 1; j++) {
      sum += A[j];
      if (sum == 0) {
        ans++;
      }
      if (all == sum) {
        ans++;
      }
    }
    all -= (A[i] + A[N - i - 1]);
  }
  printf("%lld\n", ans);
  return 0;
}
