import java.util.*;

public class cfTask2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int[] mas = new int[n];
        int count1 = 0;
        int count2 = 0;

        for (int i = 0; i < n; i++) {
            mas[i] = in.nextInt();
        }

        Arrays.sort(mas);

        for (int i = 0; i < n; i++) {
            if (mas[i] % 2 == 0) {
                count2++;
            } else {
                count1++;
            }
        }

        if (count1 == count2 + 1 || count1 == count2 || count2 == count1 + 1) {
            System.out.println("0");
        } else if (count1 == 0 || count2 == 0) {
            int sum = 0;
            int max = 0;
            for (int i = 0; i < n; i++) {
                if (max < mas[i]) {
                    max = mas[i];
                }
                sum += mas[i];
            }
            System.out.println(sum - max);
        } else {
            int reduce1 = count1;
            int reduce2 = count2;

            while (reduce1 > 0 && reduce2 > 0) {
                Arrays.sort(mas);

                for (int i = n-1; i >= 0; i--) {
                    if (mas[i] % 2 == 0) {
                        reduce2--;
                        mas[i] = 0;
                        break;
                    }
                }

                for (int i = n-1; i >= 0; i--) {
                    if (mas[i] % 2 != 0) {
                        reduce1--;
                        mas[i] = 0;
                        break;
                    }
                }
            }

            int sum2 = 0;

            for (int i = 0; i < n; i++) {
                sum2 += mas[i];
            }

            System.out.println(sum2);
        }
    }
}
