import java.io.*;
import java.util.*;
import java.lang.*;

public class Rextester{
    static void shuffle(int[] array){
        Random rand = new Random();
        for(int i=0;i<array.length;i++){
            int x = rand.nextInt(array.length-i)+i;
            int temp = array[x];
            array[x]=array[i];
            array[i]=temp;
        }
    }
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = new Integer(br.readLine());
        StringTokenizer st = new StringTokenizer(br.readLine());
        br.close();
        int[] odd = new int[n];
        int[] even = new int[n];
        Arrays.fill(odd,-1);
        Arrays.fill(even,-1);
        int o=0,e=0;
        long sum=0;
        for(int i=0;i<n;i++){
            int x = new Integer(st.nextToken());
            if(x%2==0){
                even[e++]=x;
            }
            else{
                odd[o++]=x;
            }
            sum+=x;
        }
        shuffle(even);
        shuffle(odd);
        Arrays.sort(even);
        Arrays.sort(odd);
        int i=n-1;
        while(odd[i]!=-1&&even[i]!=-1){
            sum-=odd[i];
            sum-=even[i];
            //System.out.println(odd[i]+" "+even[i]);
            i--;
        }
        if(odd[i]!=-1||even[i]!=-1){
            sum-=Math.max(odd[i],even[i]);
        }
        System.out.println(sum);
    }
}
        
        
        
        
        
        
        