import java.util.*;
public class B1144 
{
	public static void main(String args[])
	{
		Scanner in = new Scanner (System.in);
		int n;
		n=in.nextInt();
		int a[]=new int[n];
		int b[]=new int[n];
		int c[]=new int[n];
		int cEven,cOdd;
		cEven=0;
		cOdd=0;
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextInt();
			if(a[i]%2==0)
			{
				cEven++;
				b[i]=a[i];
			}
				
			else
			{
				cOdd++;
				c[i]=a[i];
			}
				
		}
		int sum=0;
		Arrays.sort(b);
		Arrays.sort(c);
		if(cEven==cOdd||cEven-1==cOdd||cEven+1==cOdd)
			System.out.println("0");
		else
		{
			if(cEven>cOdd)
			{
				for(int i=0;i<cEven-cOdd-1;i++)
					sum=sum+b[i];
			}
			else
			{
				for(int i=0;i<cEven-cOdd-1;i++)
					sum=sum+b[i];
			}
			System.out.println(sum);
		}
		
	}
}
