#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100000;
int as[MAX_N + 1];
int bs[MAX_N], cs[MAX_N];
int main() {
  int n;
  scanf("%d", &n);
  as[0] = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    as[i + 1] = as[i] + ai;
  }
  int sum = as[n];
  if (sum % 3 != 0) {
    puts("0");
    return 0;
  }
  int s1 = sum / 3, s2 = s1 * 2;
  int bn = 0, cn = 0;
  for (int i = 1; i < n; i++) {
    if (as[i] == s1) bs[bn++] = i;
    if (as[i] == s2) cs[cn++] = i;
  }
  long long cnt = 0;
  for (int i = 0; i < bn; i++) {
    int j = upper_bound(cs, cs + cn, bs[i]) - cs;
    cnt += cn - j;
  }
  printf("%lld\n", cnt);
  return 0;
}
