#include <bits/stdc++.h>
using namespace std;
long long ka[110000], ki[110000];
int n;
long long cal(void) {
  long long t = 0, ret = 0;
  for (int i = 0; i < n - 1; i++) {
    if (ki[i] * 3 == ki[n - 1] * 2) ret += t;
    if (ki[i] * 3 == ki[n - 1]) t++;
  }
  return ret;
}
int main() {
  long long i, a, s = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a;
    s += a;
    ka[i] = a;
    ki[i] = s;
  }
  cout << cal() << endl;
  return 0;
}
