#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 100010;
int sum[maxn];
int main() {
  int i, n, ct, a, b;
  long long ans;
  while (~scanf("%d", &n)) {
    ans = ct = 0;
    for (i = 1; i <= n; i++) scanf("%d", &sum[i]), sum[i] += sum[i - 1];
    if (sum[n] % 3 != 0) {
      printf("0\n");
      continue;
    }
    a = sum[n] / 3, b = 2 * a;
    for (i = 2; i < n; i++) {
      if (sum[i - 1] == a) ct++;
      if (sum[i] == b) ans += ct;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
