#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 9;
int pre[MAX], suf[MAX], a[MAX];
long long ans = 0, cnt = 0;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i], pre[i] = (i > 0 ? pre[i - 1] + a[i] : a[i]);
  int sum = pre[n - 1] / 3;
  if (pre[n - 1] % 3 != 0) return cout << 0, 0;
  for (int i = n - 1; i >= 0; i--) suf[i] = suf[i + 1] + a[i];
  if (pre[0] == sum) cnt++;
  for (int i = 2; i < n; i++) {
    if (suf[i] == sum) ans += cnt;
    if (pre[i - 1] == sum) cnt++;
  }
  cout << ans;
}
