import java.util.ArrayList;
import java.lang.Math;
import java.util.Scanner;
public class ParityAlternatedDeletions {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int maxLength = input.nextInt();
        ArrayList<Integer> evens = new ArrayList<Integer>(maxLength);
        int m = 0;
        ArrayList<Integer> odds = new ArrayList<Integer>(maxLength);
        int n = 0;
        for (int i = 0; i < maxLength; i++) {
            int num = input.nextInt();
            switch (num % 2) {
                case 0:
                    evens.add(num);
                    break;
                    default:
                        odds.add(num);
            }
        }
        evens.sort(Integer::compareTo);
        odds.sort(Integer::compareTo);
        int r = evens.size() - odds.size();
        if(Math.abs(r) <= 1)
            System.out.print(0);
        else if (r > 0) {
            int result = 0;
            for(int i = 1; i < r; i++)
                result += evens.get(i);
            System.out.print(result);
        } else {
            int result = 0;
            for(int i = 1; i < Math.abs(r); i++)
                result += odds.get(i);
            System.out.print(result);
        }
    }
}