#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int n, a[maxn], v;
long long b, s[maxn], d;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  s[0] = a[0];
  for (int i = 1; i < n; i++) s[i] = s[i - 1] + a[i];
  for (int i = 0; i < n - 1; i++) {
    if (s[i] * 3 == 2 * s[n - 1]) d += b;
    if (s[i] * 3 == s[n - 1]) b++;
  }
  cout << d << endl;
  cin >> v;
  return 0;
}
