import java.util.Scanner;
import java.util.Arrays;
import java.lang.Math.*;

public class Task {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        String end = in.nextLine();
        
        int b;
        int[] s1 = new int[a];
        int[] s2 = new int[a];
        int j = 0;
        int k = 0;
        
        for (int i=0; i<a; i++) {
            b = in.nextInt();
            if (b % 2 == 1) {
                s1[j] = b;
                j++;
            } 
            else {
                s2[k] = b;
                k++;
            }
        }
        
        Arrays.sort(s1);
        Arrays.sort(s2);
        
        int res = 0;
        
        if (j > k) {
            for (int p = 0; p < j - k - 1; p++) {
                res += s1[p];
            }
        }
        else if (k > j) {
            for (int p = 0; p < k - j - 1; p++) {
                res += s2[p];
            }
        }
        else {
            
        }
        
        System.out.println(res);
        System.exit(0);
    }
    
    static class Helper {
        public boolean isGood(String str) {
            boolean res = true;
            for (int i=1; i<str.length(); i++) {
                //System.out.println(str.charAt(i-1) + " " + str.charAt(i));
                if (str.charAt(i) != str.charAt(i-1) + 1) {
                    res = false;
                    break;
                }
            }
            return res;
        }
    }
}