#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#include<cctype>usingnamespacestd;
int dis[51],rec[51],n,ToT,ans;
inlineint read()
{
int ret=0;char ch=getchar();
for (;!isdigit(ch);ch=getchar());
for (;isdigit(ch);ch=getchar()) ret=ret*10+ch-'0';
return ret;
}
int main()
{
n=read();
for (int i=1;i<=n;i++) rec[i]=read();
for (int i=1;i<=n;i++) ToT+=rec[i],dis[i+1]=dis[i]+rec[i];
for (int a=1;a<=n;a++)
for (int b=a+1;b<=n;b++)
for (int c=b+1;c<=n;c++)
for (int d=c+1;d<=n;d++)
if (dis[b]-dis[a]==dis[d]-dis[c]&&ToT-dis[d]+dis[a]==dis[c]-dis[b]) ans++;
printf("%d\n",ans);
return0;
}