#include <bits/stdc++.h>
int a[100005];
int main(void) {
  int n, sum = 0, d = 0, i;
  long long total = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
    a[i] += a[i - 1];
  }
  if (sum % 3 == 0) {
    sum /= 3;
    d = a[0] == sum;
    for (i = 1; i < n - 1; i++) {
      if (a[i] == sum * 2) total += d;
      if (a[i] == sum) ++d;
    }
  }
  printf("%I64d\n", total);
  return 0;
}
