#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int main() {
  long long ans, cnt;
  int n;
  while (cin >> n) {
    a[0] = 0;
    ans = cnt = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      a[i] += a[i - 1];
    }
    for (int i = 1; i < n; i++) {
      if (a[i] * 3 == 2 * a[n]) ans += cnt;
      if (a[i] * 3 == a[n]) cnt++;
    }
    cout << ans << endl;
  }
  return 0;
}
