#include <bits/stdc++.h>
using namespace std;
int main() {
  list<int> id;
  long long di[100100];
  long long suma[100100];
  long long n[100100];
  long long tercio;
  long long dosTercios;
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%lld", &n[i]);
  suma[0] = 0;
  for (int i = 1; i <= N; i++) suma[i] = suma[i - 1] + n[i - 1];
  tercio = suma[N] / 3;
  dosTercios = tercio + tercio;
  for (int i = 1; i < N - 1; i++)
    if (suma[i] == tercio) id.push_back(i);
  int cant = 0;
  for (int i = N - 1; i >= 1; i--) {
    di[i] = cant;
    if (suma[N] - suma[i] == tercio) cant++;
  }
  long long total = 0;
  list<int>::iterator itId = id.begin();
  while (itId != id.end()) {
    if (suma[N] - suma[*itId] == dosTercios) {
      total += di[*itId];
    }
    itId++;
  }
  printf("%lld\n", total);
  return 0;
}
