import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Vector;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Stack;
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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni();
            int[] a = in.na(n);
            Arrays.sort(a);
            Stack<Integer> odd = new Stack<>();
            Stack<Integer> even = new Stack<>();
            for (int i = 0; i < n; i++) {
                if (a[i] % 2 == 0)
                    even.push(a[i]);
                else
                    odd.push(a[i]);
            }
            int rem = n;
            boolean takeOdd = false;
            if (odd.size() > even.size())
                takeOdd = true;
            while (rem > 0) {
                if (takeOdd) {
                    if (odd.isEmpty())
                        break;
                    odd.pop();
                    takeOdd = false;
                } else {
                    if (even.isEmpty())
                        break;
                    even.pop();
                    takeOdd = true;
                }
                rem--;
            }
            long sum = 0;
            for (Integer num : even) {
                sum += num;
            }
            for (Integer num : odd) {
                sum += num;
            }
            out.println(sum);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

        public int[] na(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = ni();
            return a;
        }

    }
}

