#include <bits/stdc++.h>
using namespace std;
int main() {
  long long square[100005], x;
  int n, i;
  cin >> n;
  square[0] = 0;
  for (i = 1; i <= n; i++) {
    cin >> x;
    square[i] = x + square[i - 1];
  }
  if (square[n] % 3) {
    cout << "0" << endl;
    return 0;
  }
  long long c1, c2;
  c1 = c2 = 0;
  for (i = 1; i <= n - 1; i++)
    if (square[i] == square[n] / 3 * 2) c2++;
  for (i = 1; i <= n - 2; i++) {
    if (square[i] == square[n] / 3 * 2) c2--;
    if (square[i] == square[n] / 3) c1 += c2;
  }
  cout << c1 << endl;
  return 0;
}
