/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];
		
		int tot=0;
		for(int i=0;i<n;i++)
		{
		a[i]=sc.nextInt();
		tot+=a[i];
		}
		
		int lhs=0,rhs=0;
		int prefix=0;
		
		int y=0;
		int ans=0;
		Map<Integer,Integer> m=new HashMap<>();
		//we are going till n-1 because lhs part we are checking 
		for(int i=0;i<n-1;i++)
		{
			y=tot/3;
			//sum of ele from 0.....i
			prefix+=a[i];
			
			//putting stick after every element for partition
			lhs+=a[i];
			
			rhs=tot-lhs;
			
			if(lhs==2*y && rhs==y)
			{
				ans+=m.get(y);
			}
			m.put(prefix,m.getOrDefault(prefix,0)+1);
			
			
		}
		
		System.out.println(ans);
	}
}