#include <bits/stdc++.h>
using namespace std;
long long nn[100010], n, sum = 0, s = 0, p1 = 0, p2 = 0, i;
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> nn[i];
    sum += nn[i];
  }
  if (sum % 3 != 0) {
    cout << "0" << endl;
    return 0;
  }
  sum /= 3;
  for (i = 1; i < n; i++) {
    s += nn[i];
    if (s == 2 * sum) p2 += p1;
    if (s == sum) p1++;
  }
  cout << p2 << endl;
  return 0;
}
