#include <bits/stdc++.h>
int n, x;
int s[111111], lef[111111], rig[111111];
long long ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &s[i]);
    s[i] += s[i - 1];
  }
  if (s[n] % 3) {
    puts("0");
    return 0;
  }
  x = s[n] / 3;
  for (int i = 1; i <= n; i++) lef[i] = lef[i - 1] + (s[i] == x);
  for (int i = n - 1; i > 0; i--) rig[i] = rig[i - 1] + (s[i] == 2 * x);
  ans = 0LL;
  for (int i = 1; i < n; i++) ans += 1LL * lef[i] * rig[i + 1];
  printf("%I64d\n", ans);
  return 0;
}
