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

public class JavaApplication4 {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int evenNum = 0;
        int oddNum = 0;
        int counter=0;
        int sum=0;
        int[] arr = new int[n];
        
        if(n==1)
            System.out.println("0");
        else{
            for (int i = 0; i < n; i++) {
                int x = sc.nextInt();
                if(x%2==0)
                    evenNum++;
                else
                    oddNum++;
                arr[i] = x;
            }
            if((evenNum-oddNum)==0 || Math.abs(evenNum-oddNum)==1 )
                System.out.println("0");
            else{
                Arrays.sort(arr);
                if(evenNum > oddNum){
                    counter = evenNum-oddNum-1;
                    for (int i = 0; i < n && counter != 0; i++) {
                        if(arr[i]%2==0){
                            counter--;
                            sum+=arr[i];
                        }    
                    }
                    System.out.println(sum);
                }
                else{
                    counter = oddNum-evenNum-1;
                    for (int i = 0; i < n && counter != 0; i++) {
                        
                        if(arr[i]%2!=0){
                            counter--;
                            sum+=arr[i];
                        }          
                    }
                    System.out.println(sum);
                }
            } 
        }
    }   
}