#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 7;
int n;
int a[N], x[N], y[N];
long long t;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i], a[i] += a[i - 1];
  if (a[n] % 3) return printf("0"), 0;
  for (int i = 1; i <= n; ++i) {
    x[i] = x[i - 1], y[i] = y[i - 1];
    if (a[i] == a[n] / 3) ++x[i];
    if (a[i] == a[n] / 3 * 2 && i < n) ++y[i], t += 1ll * x[i - 1];
  }
  printf("%I64d", t);
  return 0;
}
