#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100024;
const int INF = 0x0fffffff;
int n;
int num[MAXN];
int sum1[MAXN];
int sum2[MAXN];
int cnt2[MAXN];
long long solve(int value) {
  sum1[0] = num[0];
  for (int i = 1; i < n; ++i) {
    sum1[i] = sum1[i - 1] + num[i];
  }
  sum2[n - 1] = num[n - 1];
  for (int i = n - 2; i >= 0; --i) {
    sum2[i] = sum2[i + 1] + num[i];
  }
  for (int i = n - 1; i >= 0; --i) {
    if (sum2[i] == value) {
      if (i == n - 1)
        cnt2[i] = 1;
      else
        cnt2[i] = cnt2[i + 1] + 1;
    } else {
      if (i == n - 1)
        cnt2[i] = 0;
      else
        cnt2[i] = cnt2[i + 1];
    }
  }
  long long res = 0;
  for (int i = 0; i < n - 2; ++i) {
    if (sum1[i] == value) res += cnt2[i + 2];
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &num[i]);
  }
  int _sum = 0;
  for (int i = 0; i < n; ++i) {
    _sum += num[i];
  }
  if (_sum % 3 != 0)
    printf("0\n");
  else {
    cout << solve(_sum / 3) << endl;
  }
  return 0;
}
