#include <bits/stdc++.h>
using namespace std;
long long a[100000 + 5], sum[100000 + 5];
int main() {
  int n, i;
  long long ans, x;
  memset(sum, 0, sizeof(sum));
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%llld", &a[i]);
    sum[i] = sum[i - 1] + a[i];
  }
  ans = 0;
  memset(a, 0, sizeof(a));
  for (i = 1; i <= n; i++) {
    a[i] = a[i - 1];
    if (3 * sum[i] == sum[n]) a[i]++;
  }
  ans = 0;
  for (i = n - 1; i >= 1; i--) {
    x = sum[n] - sum[i];
    if (3 * x == sum[n]) {
      if (i >= 1) ans += a[i - 1];
    }
  }
  printf("%lld\n", ans);
  return 0;
}
