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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author jiamg
 */
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();
            int[] odd = new int[n + 1];
            int[] even = new int[n + 1];
            int id1 = 0, id2 = 0;
            int sum = 0;
            for (int i = 1; i <= n; i++) {
                int x = in.nextInt();
                sum += x;
                if (x % 2 == 0) even[++id2] = x;
                else odd[++id1] = x;
            }
            Arrays.sort(odd, 1, id1 + 1);
            Arrays.sort(even, 1, id2 + 1);
            if (id1 == id2) {
                out.println(0);
            } else if (Math.abs(id1 - id2) == 1) {
                out.println(0);
            } else {
                int cnt = Math.min(id1, id2);
                int ans = 0;
                for (int i = 1; i <= id1 - cnt; i++) ans += odd[i];
                for (int i = 1; i <= id2 - cnt; i++) ans += even[i];
                if (id1 < id2) ans -= even[id2 - cnt];
                else ans -= even[id1 - cnt];
                out.println(ans);
            }
        }

    }

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

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

        public boolean hasNext() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) return false;
                    tokenizer = new StringTokenizer(line);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return true;
        }

        public String next() {
            if (hasNext())
                return tokenizer.nextToken();
            return null;
        }

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

    }
}

