#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 9;
long long n, sum, ans, cur;
long long l[N], r[N], a[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i < (n); i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum % 3) {
    cout << 0;
    return 0;
  }
  sum /= 3;
  for (long long i = 0; i < (n); i++) l[i] = l[i - 1] * bool(i) + a[i];
  for (long long i = 0; i < (n); i++) r[n - i - 1] = r[n - i] + a[n - i - 1];
  for (long long i = 0; i < (n); i++) {
    if (r[i] == sum) ans += cur;
    if (l[i - 1] == sum && i - 1 >= 0) cur++;
  }
  cout << ans << endl;
}
