#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void mini(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void maxi(T &a, T b) {
  if (b > a) a = b;
}
int main() {
  int n;
  int A[100010];
  int C[100010];
  long long B[100010];
  cin >> n;
  int suma = 0;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    C[i] = A[i];
    suma += A[i];
  }
  memset(B, 0, sizeof B);
  if (suma % 3 != 0) {
    cout << "0\n";
    return 0;
  }
  int part = suma / 3;
  if (A[n - 1] == part) B[n - 1] = 1;
  for (int i = n - 2; i >= 0; i--) {
    A[i] += A[i + 1];
    if (A[i] == part) B[i] = 1;
  }
  for (int i = n - 2; i >= 0; i--) B[i] += B[i + 1];
  long long ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (C[i] == part) {
      ans += B[i + 2];
    }
    C[i + 1] += C[i];
  }
  cout << ans << endl;
  return 0;
}
