#include <bits/stdc++.h>
using namespace std;
long long tree[100010];
void push(int p) {
  for (; p < 100010; p += (p & (-p))) tree[p]++;
}
long long get(int p) {
  long long ret = 0;
  for (; p > 0; p -= (p & (-p))) ret += tree[p];
  return ret;
}
int sum[100010], n;
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &sum[i]);
    sum[i] += sum[i - 1];
  }
  long long tar = sum[n] / 3, ans(0);
  if (3 * tar != sum[n]) {
    printf("0\n");
    goto end;
  }
  for (i = 1; i <= n; i++)
    if (sum[i] == tar) push(i);
  for (i = 2; i < n; i++)
    if (sum[i] == 2 * tar) ans += get(i - 1);
  cout << ans << '\n';
end:
  return 0;
}
