import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class probB {
    public static void main(String[] args) throws IOException{
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(System.out);
        List<Integer> odd = new ArrayList<>();
        List<Integer> even = new ArrayList<>();
        int n = sc.nextInt();
        int sum = 0;
        for (int i = 0; i < n; i++) {
            int temp = sc.nextInt();
            sum += temp;
            if((temp %2)==1) odd.add(temp);
            else even.add(temp);
        }
        even.sort(Collections.reverseOrder());
        odd.sort(Collections.reverseOrder());
        //Collections.sort(even, Collections.reverseOrder());
        //Collections.sort(odd, Collections.reverseOrder());
        Integer[] evenArr = new Integer[n];
        Integer[] oddArr = new Integer[n];

        evenArr = even.toArray(evenArr);
        oddArr = odd.toArray(oddArr);

        int k = Math.min(even.size(), odd.size());

        int minusSum = 0;
        int i;
        for (i = 0; i < k; i++) {
            minusSum += (evenArr[i] + oddArr[i]);
        }

        if(even.size() > k) minusSum += evenArr[i];
        if(odd.size() > k) minusSum += oddArr[i];
        out.println(sum - minusSum);
        out.flush();
    }
    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        MyScanner(String fileName) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(fileName));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        String nextLine() throws IOException {
            return br.readLine();
        }

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

        long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}
