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

import javafx.util.Pair;




public class tt
{



	
	public static void main(String args[])
	{


	Scanner s=new Scanner(System.in);

	int n=s.nextInt();


	int a[]=new int[n];


	ArrayList<Integer>even=new ArrayList<Integer>();


	ArrayList<Integer>odd=new ArrayList<Integer>();

	int evensum=0;

	int oddsum=0;

	
	for(int i=0;i<n;i++)
	{

		a[i]=s.nextInt();

		if(a[i]%2==0)
		{
			even.add(a[i]);

			evensum=evensum+a[i];
		}

		else
		{
			odd.add(a[i]);

			oddsum=oddsum+a[i];
		}

	}


	if(even.isEmpty())
	{

		Collections.sort(odd,Collections.reverseOrder());

		odd.remove(0);

		int ans=0;


		for( int e : odd)
		{
			ans=ans+e;
		}


		System.out.println(ans);
	}

	else if(odd.isEmpty())
	{

		Collections.sort(even,Collections.reverseOrder());

		even.remove(0);

		int ans=0;


		for( int e : even)
		{
			ans=ans+e;
		}


		System.out.println(ans);



	}


	


	else
	{

		Collections.sort(odd,Collections.reverseOrder());

		Collections.sort(even,Collections.reverseOrder());

		int k=0;


		if(even.size()>odd.size())
		{

		while((!even.isEmpty())&&(!odd.isEmpty()))
		{
			even.remove(k);

			odd.remove(k);

			


		}

		even.remove(0);


		int sum=0;

			for(int x : even)
			{
				sum=sum+x;
			}

			System.out.println(sum);




	}




	else if(even.size()<odd.size())
		{

		while((!even.isEmpty())&&(!odd.isEmpty()))
		{

			odd.remove(k);
			even.remove(k);

			

			


		}

		odd.remove(0);


		int sum=0;

			for(int x : odd)
			{
				sum=sum+x;
			}

			System.out.println(sum);




	}


	else

	{

		System.out.println(0);
	}







		




	}
	
	}


}


