#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n, a[N];
long long solve() {
  int sum = accumulate(a + 1, a + 1 + n, 0);
  if (sum % 3) return 0;
  sum /= 3;
  long long ret = 0;
  deque<int> suf;
  int ss = 0;
  for (int i = (0); i < (n); ++i) {
    ss += a[n - i];
    if (ss == sum) suf.push_front(n - i);
  }
  ss = 0;
  for (int i = (1); i < (n + 1); ++i) {
    ss += a[i];
    if (ss != sum) continue;
    while (!suf.empty() && suf.front() <= i + 1) suf.pop_front();
    ret += ((int)(suf).size());
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = (1); i < (n + 1); ++i) scanf("%d", a + i);
  cout << solve() << endl;
  return 0;
}
