import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        ArrayList<Integer> odd = new ArrayList<>();
        ArrayList<Integer> even = new ArrayList<>();
        
        for(int i = 0; i < n; i++){
            arr[i] = sc.nextInt();
            if(arr[i] % 2 != 0)
                odd.add(arr[i]);
            else
                even.add(arr[i]);
        }
        
        int i = 0, j = 0, k = 0;
        int sum = 0;
        
        Collections.sort(odd, Collections.reverseOrder());
        Collections.sort(even, Collections.reverseOrder());
        
        while(odd.size() > 0 && even.size() > 0){
            if(k % 2 == 0){
                odd.remove(0);
            }
            else{
                even.remove(0);
            }
            k += 1;
        }
        
        if(odd.size() > 0){
            odd.remove(0);
            for( int l : odd)
                sum += l;
        }
        else{
            even.remove(0);
            for( int l : even)
                sum += l;
        }
        
        System.out.println(sum);
    }
}
