import java.util.Arrays;
import java.util.Scanner;

public class ParityAlternatedDeletions {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int[] a = new int[n];
        int even = 0, odd = 0, br = 0, res = 0;
        for(int i = 0; i < n; i++) {
            a[i] = s.nextInt();
            if(a[i] % 2 == 0) even++;
            else odd++;
        }
        Arrays.sort(a);
        if(Math.abs(even - odd) == 1 || even == odd) res = 0;
        else {
            int j = Math.abs(even - odd);
            if(even == 0 || odd == 0) j--;
            int k = 0;
            if(even > odd) {
                while(k < n && br < j) {
                    if(a[k] % 2 == 0) {
                        res += a[k];
                        br++;
                    }
                    k++;
                }
            }
            else {
                while(k < n && br < j) {
                    if(a[k] % 2 == 1) {
                        res += a[k];
                        br++;
                    }
                    k++;
                }
            }
        }
        System.out.println(res);
    }
}
