#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, maxn = 100005;
int n, a[maxn], s[maxn], num[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    s[i] = s[i - 1] + a[i];
  }
  if (s[n] % 3)
    printf("0\n");
  else {
    int x = s[n] / 3;
    long long ans = 0;
    for (int i = 1; i <= n; i++) num[i] = num[i - 1] + (s[i] == x);
    int res = 0;
    for (int i = n; i > 2; i--) {
      res += a[i];
      if (res == x) ans += num[i - 2];
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
