#include <bits/stdc++.h>
using namespace std;
template <typename T, typename V>
void bugp(const pair<T, V> &x) {
  cerr << '{' << x.first << ", " << x.second << '}' << endl;
}
template <typename T, typename U, typename V>
void bugpp(const pair<T, pair<U, V> > &x) {
  cerr << '{' << x.first << ", {" << x.second.first << ", " << x.second.second
       << "}}" << endl;
}
template <typename T>
bool maximize(T &x, const T &y) {
  if (x < y) {
    x = y;
    return 1;
  }
  return 0;
}
template <typename T>
bool minimize(T &x, const T &y) {
  if (x > y) {
    x = y;
    return 1;
  }
  return 0;
}
const int N = 100001;
int n, arr[N], dp[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  int total_sum = 0;
  map<int, int> cnt;
  for (int i = 1, _n = (n); i <= _n; ++i) {
    cin >> arr[i];
    total_sum += arr[i];
    if (!(total_sum & 1)) dp[i] = cnt[total_sum - total_sum / 2];
    ++cnt[total_sum];
  }
  long long ans = 0;
  int sum = 0;
  for (int i = (n), _b = (3); i >= _b; --i) {
    sum += arr[i];
    if (3 * sum == total_sum) ans += dp[i - 1];
  }
  cout << ans;
  return 0;
}
