#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
int sa[N];
vector<int> v[2];
int main() {
  int n, tp;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &tp);
    sa[i] = sa[i - 1] + tp;
  }
  if (n < 3 || sa[n] % 3) {
    puts("0");
    return 0;
  }
  int avg = sa[n] / 3;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (sa[i] == avg)
      v[0].push_back(i);
    else if (sa[i] == avg * 2)
      v[1].push_back(i);
  }
  if (avg) {
    for (int i = 0; i < v[0].size(); i++)
      ans += v[1].end() - upper_bound(v[1].begin(), v[1].end(), v[0][i]);
  } else {
    long long x = v[0].size() - 1;
    ans = x * (x - 1) / 2;
  }
  printf("%I64d", ans);
  return 0;
}
