/* package codechef; // 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. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] arr=new int[n];
		int odd=0,even=0;
		for(int i=0;i<n;i++)
		{
		    arr[i]=sc.nextInt();
		    if(arr[i]%2==0)
		    even++;
		    else
		    odd++;
		}
		if(odd==even || odd+1==even || even+1==odd)
		{
		    System.out.print(0);
		    return;
		}
		if(odd==0 || even==0)
		{
		    int max=Integer.MIN_VALUE;
		    int s=0;
		    for(int i=0;i<n;i++)
		    {
		        s=s+arr[i];
		    max=Math.max(max,arr[i]);
		    }
		    System.out.println(s-max);
		    return;
		    
		}
		Arrays.sort(arr);
		int oi=n-1;
		int ei=n-1;
		
		int t=Math.min(odd,even);
		for(int x=1;x<=t;x++)
		    {
		        while(arr[oi]%2==0)
		        {
		            oi--;
		        }
		        while(arr[ei]%2==1)
		        {
		            ei--;
		        }
		        arr[oi]=0;
		        arr[ei]=0;
		    }
		if(odd>even)
		{
		    
		    while(arr[oi]%2==0)
		    oi--;
		    arr[oi]=0;
		}
		else
		{
		    while(arr[ei]%2==1)
		    ei--;
		    arr[ei]=0;
		}
		
		int sum=0;
		for(int i=0;i<n;i++)
		sum=sum+arr[i];
		System.out.println(sum);
		
		
		
	}
}
