#include <bits/stdc++.h>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const int maxn = 1000 * 100 + 10;
int a[maxn];
int s[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i], s[i] = s[i - 1] + a[i];
  if (s[n] % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  int tot = 0;
  long long ans = 0;
  for (int i = n - 1; i; --i) {
    if (i < n - 1 && s[i] == s[n] / 3) ans += 1LL * tot;
    if (s[i] == (s[n] * 2) / 3) tot++;
  }
  cout << ans << endl;
  return 0;
}
