import java.util.Scanner;
import java.util.PriorityQueue;
public class B {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PriorityQueue<Integer> quEven = new PriorityQueue<>();
		PriorityQueue<Integer> quOdd = new PriorityQueue<>();

		int n = sc.nextInt();
		int numOdd = 0, numEven = 0;
		for(int i = 0; i < n; i++) {
			int x = sc.nextInt();
			if(x % 2 == 0) {
				numEven++;
				quEven.add(x);
			} else {
				numOdd++;
				quOdd.add(x);
			}
		}
		
		if(Math.abs(numEven - numOdd) <= 1)
			System.out.println(0);
		else {
			int diff = Math.abs(numEven - numOdd) - 1;
			int sum = 0;
			if(numEven > numOdd) {
				while(diff-->0)
					sum += quEven.poll();
			} else {
				sum += quOdd.poll();
			}
			System.out.println(sum);
		}
	}
}
