#include <bits/stdc++.h>
using namespace std;
int N, psum[100005];
map<int, int> m;
int main() {
  long long res = 0;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    int n;
    scanf("%d", &n);
    psum[i] = psum[i - 1] + n;
    m[psum[i]]++;
  }
  m[psum[N]]--;
  if (psum[N] % 3) {
    printf("%d\n", 0);
    return 0;
  }
  for (int i = 1; i <= N - 2; i++) {
    m[psum[i]]--;
    if (psum[i] == psum[N] / 3) {
      res += m[2 * psum[i]];
    }
  }
  cout << res << endl;
  return 0;
}
