#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, a[N];
vector<int> u, v;
long long before[N] = {0}, behind[N] = {0};
int main() {
  cin >> n;
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum % 3) {
    puts("0");
    return 0;
  }
  sum /= 3;
  for (int i = 1; i <= n; i++) {
    before[i] = before[i - 1] + a[i];
    if (before[i] == sum) u.push_back(i);
  }
  for (int i = n; i >= 1; i--) {
    behind[i] = behind[i + 1] + a[i];
    if (behind[i] == sum) v.push_back(i);
  }
  sort(v.begin(), v.end());
  long long ans = 0;
  for (int i = 0; i < u.size(); i++) {
    int p = upper_bound(v.begin(), v.end(), u[i] + 1) - v.begin();
    ans += v.size() - p;
  }
  cout << ans << endl;
  return 0;
}
