
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
int a[N];
int main (){
int x;
cin >> x;
for(int i = 1;i<=x;i++){
int y ;
cin >> y;
a[i] = a[i-1] + y;
}
if(a[x]%3)cout<<"0";
else {
long long res = 0 ,cnt = 0;
for(int j = 2;j < x;j++){
if(a[j-1]==a[x]/3)res++;
if(a[j]==a[x]/3*2)cnt+=res;
}
cout<<cnt;
}
return 0;
}