import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        sc.nextLine();

        List<Integer> nums = Arrays.asList(sc.nextLine().split(" "))
                .stream()
                .map(s -> Integer.valueOf(s))
                .collect(Collectors.toList());
        Collections.sort(nums, Collections.reverseOrder());


        List<Integer> evenNums = new ArrayList<>();
        List<Integer> oddNums = new ArrayList<>();
        for (int i = 0; i< nums.size(); i++) {
            Integer n = nums.get(i);
            if (n % 2 == 0) {
                evenNums.add(n);
            } else {
                oddNums.add(n);
            }
        }

        int result = 0;

        if (Math.abs(evenNums.size() - oddNums.size()) <= 1) {
            result = 0;
            System.out.println(result);
            return;
        }

        if (oddNums.size() == 0) {
            result = sum(evenNums, 1);
            System.out.println(result);
            return;
        }

        if (evenNums.size() == 0) {
            result = sum(oddNums, 1);
            System.out.println(result);
            return;
        }
        
        if (evenNums.size() > oddNums.size()) {
            int delta = evenNums.size() - oddNums.size();
            for (int i = delta; i < evenNums.size(); i++) {
                result += evenNums.get(i);
            }
            System.out.println(result);
        } else {
            int delta = oddNums.size() - evenNums.size();
            for (int i = delta; i < oddNums.size(); i++) {
                result += oddNums.get(i);
            }
            System.out.println(result);
        }

    }
    
    private static int sum(List<Integer> nums, int startIndex) {
        int result = 0;
        for (int i = startIndex; i < nums.size(); i++) {
            result += nums.get(i);
        }
        return result;
    }
}