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