#include <bits/stdc++.h>
#pragma comment(linker, "/stack:64000000")
using namespace std;
template <typename first>
inline first abs(const first& a) {
  return a < 0 ? -a : a;
}
template <typename first>
inline first sqr(const first& a) {
  return a * a;
}
using namespace std;
const int N = 100000 + 13;
long long s = 0, a[N];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < int(n); i++) scanf("%I64d", &a[i]), s += a[i];
  long long cur = 0, ans = 0;
  map<long long, long long> z;
  for (int i = 0; i < int(n); i++) {
    cur += a[i];
    if (i == 0 || i == n - 1) {
      z[cur]++;
      continue;
    }
    if ((cur & 1) == 0 && s - cur == (cur >> 1) && z.count(cur >> 1))
      ans += z[cur >> 1];
    z[cur]++;
  }
  cout << ans << endl;
  return 0;
}
