

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc=new Scanner (System.in);
		int n=sc.nextInt();
		int todd=0;int teven=0,a;
		int odd[]=new int[n],even[]=new int[n];
		for(int i=0;i<n;i++) {
			a=sc.nextInt();
			if(a%2==0) {//a为偶
				even[teven++]=a;
			}else {
				odd[todd++]=a;
			}
		}
		Arrays.sort(even, 0, teven);
		Arrays.sort(odd, 0, todd);
		long ans=0;
		if(todd>teven) {
			for(int i=teven+1;i<todd;i++) {
				ans+=odd[i];
			}
		}else if(todd<teven){
			for(int i=todd+1;i<teven;i++) {
				ans+=even[i];
			}
		}else {
			ans=0;
		}
		System.out.println(ans);
	}
}
