import java.io.*;
import java.util.*;
 
public class ParityAlternatedDeletions
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
 
		int n = Integer.parseInt(st.nextToken());
		ArrayList<Integer> evennumarr = new ArrayList<Integer>();
		ArrayList<Integer> oddnumarr = new ArrayList<Integer>();

	      st = new StringTokenizer(br.readLine());
	      for(int i=0; i<n; i++)
		{
                  int num = Integer.parseInt(st.nextToken());
                  if(num %2 == 0) 
                        evennumarr.add(num);
                  else 
                        oddnumarr.add(num);
		}
		
		int range = Math.abs(evennumarr.size() - oddnumarr.size());
	      if(range == 1)
	            System.out.println(0);
            else
            {
                  Collections.sort(evennumarr);
                  Collections.sort(oddnumarr);
                  int minsum = 0;
                  if(evennumarr.size() > oddnumarr.size())
                  {
                        for(int i=0; i<range-1; i++)
                        {
                              minsum += evennumarr.get(i);
                        }
                  }
                  else
                  {
                        for(int i=0; i<range-1; i++)
                        {
                              minsum += oddnumarr.get(i);
                        }
                  }
                  System.out.println(minsum);
            }
	}
}