import java.util.*;

public class Question1144B {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        List<Integer> evenList=new ArrayList<>();
        List<Integer> oddList=new ArrayList<>();
        int[] arr=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
            if(arr[i]%2==0){
                evenList.add(arr[i]);
            }
            else {
                oddList.add(arr[i]);
            }
        }

        if(evenList.size()==oddList.size()){
            System.out.println("0");
        }
        else if(evenList.size()-1==oddList.size()||oddList.size()-1==evenList.size()){
            System.out.println("0");
        }
        else {
            Collections.sort(evenList, new Comparator<Integer>() {
                @Override
                public int compare(Integer o1, Integer o2) {
                    return Integer.compare(o2,o1);
                }
            });
            Collections.sort(oddList, new Comparator<Integer>() {
                @Override
                public int compare(Integer o1, Integer o2) {
                    return Integer.compare(o2,o1);
                }
            });
            long sum=0;

//            System.out.println(evenList);
//            System.out.println(oddList);
            if(evenList.size()>oddList.size()){
                int count=evenList.size()-oddList.size();
                int i=evenList.size()-1;
                int x=0;
                while (i>0){
                    sum+=evenList.get(i);
                    i--;
                    x++;
                    if(x==count-1){
                        break;
                    }
                }

            }else {
                int count=oddList.size()-evenList.size();
                //System.out.println(count);
                int i=oddList.size()-1;
                int x=0;
                while (i>0){
                    sum+=oddList.get(i);
                    i--;
                    x++;
                    if(x==count-1){
                        break;
                    }
                }

            }
            System.out.println(sum);
        }
    }
}
