import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ky112233
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BParityAlternatedDeletions solver = new BParityAlternatedDeletions();
        solver.solve(1, in, out);
        out.close();
    }

    static class BParityAlternatedDeletions {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            Arrays.sort(a);
            int oddCnt = 0, evenCnt = 0;
            for (int i = 0; i < n; i++) {
                if (a[i] % 2 == 0) evenCnt++;
                else oddCnt++;
            }
            if (Math.abs(oddCnt - evenCnt) <= 1) {
                out.println(0);
                return;
            }
            int mn = Math.min(oddCnt, evenCnt);
            int temp = mn;
            int[] deleted = new int[n];
            for (int i = n - 1; i >= 0; i--) {
                if (a[i] % 2 == 0 && temp > 0) {
                    temp--;
                    deleted[i] = 1;
                }
            }
            temp = mn;
            for (int i = n - 1; i >= 0; i--) {
                if (a[i] % 2 == 1 && temp > 0) {
                    temp--;
                    deleted[i] = 1;
                }
            }
            if (oddCnt > evenCnt) {
                for (int i = n - 1; i >= 0; i--) {
                    if (a[i] % 2 == 1 && deleted[i] == 0) {
                        deleted[i] = 1;
                        break;
                    }
                }
                int sum = 0;
                for (int i = 0; i < n; i++) {
                    if (deleted[i] == 0) sum += a[i];
                }
                out.println(sum);
            } else {
                for (int i = n - 1; i >= 0; i--) {
                    if (a[i] % 2 == 0 && deleted[i] == 0) {
                        deleted[i] = 1;
                        break;
                    }
                }
                int sum = 0;
                for (int i = 0; i < n; i++) {
                    if (deleted[i] == 0) sum += a[i];
                }
                out.println(sum);
            }
        }

    }
}

