#include <bits/stdc++.h>
int main() {
  static int pp[100000], qq[100000];
  int n, i, sum, cnt;
  long long ans;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    pp[i] = qq[i] = a;
  }
  for (i = 1; i < n; i++) pp[i] += pp[i - 1];
  for (i = n - 2; i >= 0; i--) qq[i] += qq[i + 1];
  if (pp[n - 1] % 3 != 0) {
    printf("0\n");
    return 0;
  }
  sum = pp[n - 1] / 3;
  ans = 0, cnt = 0;
  for (i = 0; i + 2 < n; i++) {
    if (pp[i] == sum) cnt++;
    if (qq[i + 2] == sum) ans += cnt;
  }
  printf("%lld\n", ans);
  return 0;
}
