#include <bits/stdc++.h>
using namespace std;
long long sum[100005], a[100005], vis1[100005], vis2[100005];
int main() {
  long long i, n, ave, ans;
  while (scanf("%I64d", &n) != EOF) {
    memset(sum, 0, sizeof(sum));
    for (i = 1; i <= n; i++) {
      scanf("%I64d", &a[i]);
      sum[i] = sum[i - 1] + a[i];
    }
    ans = 0;
    if (n == 1 || n == 2 || sum[n] % 3) {
      puts("0");
      continue;
    }
    ave = sum[n] / 3;
    memset(vis1, 0, sizeof(vis1));
    memset(vis2, 0, sizeof(vis2));
    for (i = 1; i <= n; i++) {
      if (sum[i] == ave) {
        vis1[i] = vis1[i - 1] + 1;
      } else
        vis1[i] = vis1[i - 1];
    }
    for (i = n - 1; i > 1; i--) {
      if (sum[n] - sum[i] == ave) {
        ans += vis1[i - 1];
      }
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
