import java.util.PriorityQueue;
import java.util.Scanner;


public class ParityAlternatedDeletions {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        PriorityQueue<Integer> oddHeap = new PriorityQueue<>((x,y) -> y -x);
        PriorityQueue<Integer> evenHeap = new PriorityQueue<>((x,y) -> y -x);
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if ((a[i] & 1) == 0) evenHeap.add(a[i]);
            else oddHeap.add(a[i]);
        }

        int previousParity = -1;
        if(oddHeap.size() > evenHeap.size()) {
            oddHeap.poll();
            previousParity = 1;
        } else {
            evenHeap.poll();
            previousParity = 0;
        }

        while(!oddHeap.isEmpty() && !evenHeap.isEmpty()) {
            if (previousParity == 1) {
                evenHeap.poll();
                previousParity = 0;
            } else {
                oddHeap.poll();
                previousParity = 1;
            }
        }

        if (previousParity == 1 && !evenHeap.isEmpty()) {
            evenHeap.poll();
        } else if (previousParity == 0 && !oddHeap.isEmpty()) {
            oddHeap.poll();
        }

        if (oddHeap.isEmpty() && evenHeap.isEmpty()) {
            System.out.println(0);
        } else if(evenHeap.isEmpty()) {
            System.out.println(oddHeap.stream().reduce(0, (x, y) -> x + y));
        } else {
            System.out.println(evenHeap.stream().reduce(0, (x, y) -> x + y));
        }
    }
}