#include <bits/stdc++.h>
using namespace std;
int inp[100005], dp[100005], sum = 0;
long long ans = 0;
int main() {
  int n, i;
  cin >> n;
  inp[0] = dp[0] = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", inp + i);
    sum += inp[i];
    inp[i] += inp[i - 1];
  }
  cerr << sum << " :: ";
  if (sum % 3) {
    puts("0");
    return 0;
  }
  sum /= 3;
  for (i = 1; i <= n; i++) dp[i] = (inp[i] == sum) + dp[i - 1];
  sum *= 2;
  for (i = n - 1; i; i--)
    if (inp[i] == sum) ans += dp[i - 1];
  cout << ans;
}
