import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
public class BCF1055A {
    public static void main(String[]args)throws Exception
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        int e_count = 0;
        int o_count = 0;
        StringTokenizer st = new StringTokenizer(br.readLine());
        int arr[] = new int[n];
        for(int i=0;i<n;i++)
        {
            int no=Integer.parseInt(st.nextToken());
            arr[i]=no;
        }
        Arrays.sort(arr);
        for(int i=0;i<n;i++)
        {
            int no = arr[i];
            if(no%2==0)
                e_count++;
            else
             o_count++;
        }
//        System.out.println(e_count+" "+o_count);
        if(Math.abs(e_count-o_count)<2)
        {
            System.out.println(0);
        }
        else{
            int res=0;
            if(e_count>o_count)
            {
                int c=0;
                for(int i=0;i<n;i++)
                    if(arr[i]%2==0){
                        {
                            res+=arr[i];
                            c+=1;
                            if(c==(e_count-o_count-1))
                                break;
                        }
                    }
            }
            else
            {
                int c=0;
                for(int i=0;i<n;i++)
                    if(arr[i]%2==1){
                        res+=arr[i];
                        c+=1;
                        if(c==(o_count-e_count-1))
                            break;
                    }
            }
            System.out.println(res);
        }
    }
}
