import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<Integer> odd = new ArrayList<>();
		List<Integer> even = new ArrayList<>();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int a = in.nextInt();
			list.add(a);
			if (a % 2 == 0) {
				even.add(a);
			} else {
				odd.add(a);
			}
		}

		int x = odd.size();
		int y = even.size();

		int res[] = new int[2];
		int z = 0;
		for (z = 0; z < 2; z++) {
			if (x == y) {
				System.out.println(0);
				break;
			}
			int a = (int) (Math.random() * n);
			if (list.get(a) % 2 == 1 && x != y) {
				int min = 0;
				int index = 0;
				if (x > y) {
					index = x - y - 1;
					Collections.sort(odd);
					for (int i = 0; i < index; i++) {
						min += odd.get(i);
					}
					res[z] = min;
					// System.out.println(min);
				} else {
					index = y - x;
					Collections.sort(even);
					for (int i = 0; i < index; i++) {
						min += even.get(i);
					}
					res[z] = min;
					// System.out.println(min);
				}

			}

			if (list.get(a) % 2 == 0 && x != y) {
				int min = 0;
				int index = 0;
				if (x > y) {
					index = x - y;
					Collections.sort(odd);
					for (int i = 0; i < index; i++) {
						min += odd.get(i);
					}
					res[z] = min;
					// System.out.println(min);
				} else {
					index = y - x - 1;
					Collections.sort(even);
					for (int i = 0; i < index; i++) {
						min += even.get(i);
					}
					res[z] = min;
					// System.out.println(min);
				}
			}
		}
		if (z == 2) {
			if (res[0] < res[1]) {
				System.out.println(res[0]);
			} else {
				System.out.println(res[1]);
			}
		}

	}
}