#include <bits/stdc++.h>
using namespace std;
int n, acum[100000 + 1], A[100000 + 1];
int main() {
  int total = 0;
  scanf("%d", &n);
  acum[0] = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &A[i]);
    acum[i] = acum[i - 1] + A[i];
    total += A[i];
  }
  if (n <= 2 || total % 3 != 0) {
    puts("0");
    return 0;
  }
  int valor1 = total / 3;
  int valor2 = (total / 3) * 2;
  long long res = 0LL, ct1 = 0;
  for (int i = 1; i <= n - 1; ++i) {
    if (acum[i] == valor2) res += ct1;
    if (acum[i] == valor1) ct1++;
  }
  cout << res << endl;
}
