#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int t[MAXN], pref[MAXN];
vector<int> pos;
int main() {
  int n, a, b, c, d, e, f, s = 0;
  long long w = 0;
  scanf("%d", &n);
  for (a = 0; a < n; a++) {
    scanf("%d", &t[a]);
    s += t[a];
  }
  if (s % 3) {
    printf("0");
    return 0;
  }
  s /= 3;
  pref[0] = t[0];
  for (a = 1; a < n; a++) {
    pref[a] = pref[a - 1] + t[a];
    if (a + 1 < n && pref[a] == 2 * s) pos.push_back(a);
  }
  for (a = 0; a + 2 < n; a++)
    if (pref[a] == s) w += pos.end() - upper_bound(pos.begin(), pos.end(), a);
  printf("%lld", w);
  return 0;
}
