import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(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, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Integer[] ar = new Integer[n];
            ArrayList<Integer> evenNumbers = new ArrayList<>();
            ArrayList<Integer> oddNumbers = new ArrayList<>();
            int numberOfOdd = 0, numberOfEven = 0;
            int totalSum = 0;
            for (int i = 0; i < n; i++) {
                int cur = in.nextInt();
                ar[i] = cur;
                if (cur % 2 == 0) {
                    numberOfEven++;
                    evenNumbers.add(cur);
                } else {
                    numberOfOdd++;
                    oddNumbers.add(cur);
                }
                totalSum += ar[i];
            }
            int ans = 0;
            if (numberOfEven == 0 || numberOfOdd == 0) {
                Arrays.sort(ar);
                for (int i = 0; i < n - 1; i++)
                    ans += ar[i];
            } else {
                Collections.sort(evenNumbers);
                Collections.sort(oddNumbers);
                int min1 = getMinSum(numberOfEven, numberOfOdd, true, totalSum, evenNumbers, oddNumbers);
                int min2 = getMinSum(numberOfEven, numberOfOdd, false, totalSum, evenNumbers, oddNumbers);
                ans = Math.min(min1, min2);
            }
            out.println(ans);
        }

        private static int getMinSum(int numberOfEven, int numberOfOdd, boolean fl, int totalSum,
                                     ArrayList<Integer> evenNumbers, ArrayList<Integer> oddNumbers) {
            int choiceSum = 0;
            int i1 = numberOfEven - 1;
            int i2 = numberOfOdd - 1;
            while (true) {
                if (fl) {
                    if (i1 < 0)
                        break;
                    choiceSum += evenNumbers.get(i1);
                    i1--;
                } else {
                    if (i2 < 0)
                        break;
                    choiceSum += oddNumbers.get(i2);
                    i2--;
                }
                fl = !fl;
            }
            return totalSum - choiceSum;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

