import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		ArrayList<Integer> arr = new ArrayList<>();
		ArrayList<Integer> arr2 = new ArrayList<>();
		for (int i = 0; i < num; i++) {
			int n = sc.nextInt();
			arr.add(n);
			arr2.add(n);
		}
		Collections.sort(arr);
		int even = 0, odd = 0;
		boolean BREAK = true;
		A: for (int i = 1; i <= num; i++) { // even
			if (i % 2 == 1) {
				for (int j = arr.size() - 1; j >= 0; j--) {
					if (arr.get(j) % 2 == 1) {
						arr.remove(j);
						continue A;
					}
				}
				BREAK = false;
				break A;
			} else {
				for (int j = arr.size() - 1; j >= 0; j--) {
					if (arr.get(j) % 2 == 0) {
						arr.remove(j);
						continue A;
					}
				}
				BREAK = false;
				break A;
			}
		}
		if (!BREAK)
			for (int i = 0; i < arr.size(); i++) {
				even += arr.get(i);
			}
		BREAK = true;
		A: for (int i = 0; i < num; i++) { // odd
			if (i % 2 == 1) {
				for (int j = arr2.size() - 1; j >= 0; j--) {
					if (arr2.get(j) % 2 == 1) {
						arr2.remove(j);
						continue A;
					}
				}

				BREAK = false;
				break A;
			} else {
				for (int j = arr2.size() - 1; j >= 0; j--) {
					if (arr2.get(j) % 2 == 0) {
						arr2.remove(j);
						continue A;
					}
				}
				BREAK = false;
				break A;
			}
		}
		if (!BREAK)
			for (int i = 0; i < arr2.size(); i++) {
				odd += arr2.get(i);
			}

		if(even<=odd)
			System.out.println(even);
		else
			System.out.println(odd);
	}
}
									  	  						 		 	  	 	