#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 10;
int a[maxN];
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  if (a[n] % 3) return cout << 0 << endl, 0;
  int sumDiv3 = a[n] / 3;
  int cntLast = a[1] == sumDiv3;
  long long cnt = 0;
  for (int i = 2; i < n; ++i) {
    if (a[i] == 2 * sumDiv3) cnt += cntLast;
    if (a[i] == sumDiv3) cntLast += 1;
  }
  cout << cnt << endl;
  return 0;
}
