import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.AbstractCollection;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.AbstractQueue;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            PriorityQueue<Integer> odd = new PriorityQueue<>((p, q) -> q - p);
            PriorityQueue<Integer> even = new PriorityQueue<>((p, q) -> q - p);
            for (int i = 0; i < n; i++) {
                int num = in.nextInt();
                if (num % 2 == 0) even.add(num);
                else odd.add(num);
            }

            boolean evenFirst = even.size() > odd.size();
            while (!odd.isEmpty() && !even.isEmpty()) {
                if (evenFirst) {
                    even.remove();
                } else {
                    odd.remove();
                }
                evenFirst = !evenFirst;
            }

            if (evenFirst && !even.isEmpty()) even.remove();
            if (!evenFirst && !odd.isEmpty()) odd.remove();

            int res = 0;
            while (!odd.isEmpty()) res += odd.remove();
            while (!even.isEmpty()) res += even.remove();

            out.println(res);
        }

    }
}
