import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class BaiB {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] chan = new int[n];
		int[] le = new int[n];
		int demc = 0, deml = 0;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (a % 2 == 0) {
				chan[demc++] = a;
			} else {
				le[deml++] = a;
			}
		}
		Arrays.sort(le);
		Arrays.sort(chan);
		if (deml == demc || deml + 1 == demc || deml == demc + 1) {
			System.out.println(0);
		} else {
			int kq=0;
			if (deml > demc) {
				for(int i=0; i<deml-demc; i++)
				{
					kq+=le[i];
				}
			} else {
				for(int i=0; i<deml-demc; i++)
				{
					kq+=le[i];
				}
			}
			System.out.println(kq);
		}
	}
}
