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

public class Pair {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int data[] = new int[n];
        int evenNum = 0;
        int oddNum = 0;
        for(int i = 0; i < n; i++){
            data[i] = sc.nextInt();
            if(data[i]%2==0)
                evenNum++;
            else 
                oddNum++;
        }
        int sum = 0;
        int index = 0, k = 0;
        Arrays.sort(data);
        if(evenNum==oddNum || evenNum - oddNum ==1 || oddNum - evenNum ==1){
            System.out.println("0");

        } else{
            int dif = evenNum-oddNum;
            System.out.println(dif);
            if(dif>0) {
                dif--;
                while(index<dif){
                    if(data[k]%2==0){
                        sum +=  data[k];
                        index++;
                    }
                    k++;
                }
            } else {
                dif *= -1;
                dif --;
                while (index < dif) {
                    if (data[k] % 2 == 1) {
                        sum += data[k];
                        index++;
                    }
                    k++;
                }
            }
            System.out.print(sum);
        }
        
    }
}