#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const double PI = 3.141592653589793;
const int N = 100005;
int s, tab[N], i, n;
bool bat1[N], bat2[N];
long long jedz() {
  int k, m, i, n2;
  long long res;
  if (s % 3 != 0) return 0;
  k = s / 3;
  m = 0;
  for (i = 0; i < n; i++) {
    m += tab[i];
    if (m == k) bat1[i] = true;
  }
  m = n2 = 0;
  for (i = n - 1; i >= 0; i--) {
    m += tab[i];
    if (m == k) {
      bat2[i] = true;
      n2++;
    }
  }
  res = 0;
  if (bat2[0]) n2--;
  for (i = 0; i < n - 1; i++) {
    if (bat2[i + 1]) n2--;
    if (bat1[i]) res += n2;
  }
  return res;
}
int main() {
  scanf("%d", &n);
  s = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &tab[i]);
    s += tab[i];
  }
  cout << jedz() << endl;
  return 0;
}
