#include <bits/stdc++.h>
using namespace std;
int n, a[100005];
long long sum, gap, cnt1, cnt2;
template <typename T>
inline T read() {
  T x = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * w;
}
int main() {
  n = read<int>();
  for (int i = 1; i <= n; i++) sum += (a[i] = read<int>());
  if (sum % 3) {
    puts("0");
    return 0;
  }
  gap = sum / 3, sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += a[i];
    if (i < n) {
      if (sum == 2 * gap) cnt2 += cnt1;
      if (sum == gap) cnt1++;
    }
  }
  printf("%I64d\n", cnt2);
  return 0;
}
