
import java.util.*;
import java.math.*;
public class Main {
	static int maxn;
	static int n,a[]=new int[maxn];
	static String s=new String();
	public static void main(String args[]){
		Scanner cin=new Scanner(System.in);
		
		for(int i=1;i<=1;i++){
			n=cin.nextInt();
			int arr[]=new int[n],ji=0,ou=0,sum=0;
			for(int j=0;j<n;j++){
				arr[j]=cin.nextInt();
				if(arr[j]%2==1) ji++;
				else ou++;
				sum+=arr[j];
			}
			Arrays.sort(arr,0,n);
			boolean sign=false;
			int k=Math.min(ji,ou);
			ji=ou=k;
			for(int j=n-1;j>=0;j--){
				if(arr[j]%2==1&&ji>0) {
					sum-=arr[j];
					ji--;
				}
				else if(arr[j]%2==0&&ou>0){
					sum-=arr[j];
					ou--;
				}
				else if(!sign){
					sum-=arr[j];
					break;
				}
			}
			System.out.println(sum);
		}
	}
}