import java.util.*;

public class B {

    public static long sum(List<Long> aIn, List<Long> bIn) {
        List<Long> a = new LinkedList<>(aIn);
        List<Long> b = new LinkedList<>(bIn);

        Iterator<Long> aIterator = a.iterator();
        Iterator<Long> bIterator = b.iterator();

        Iterator<Long> iterator = aIterator;
        while (iterator.hasNext()) {
            iterator.next();
            iterator.remove();
            iterator = aIterator == iterator ? bIterator : aIterator;
        }

        long summ = 0;
        while (aIterator.hasNext()) {
            summ += aIterator.next();
        }

        while (bIterator.hasNext()) {
            summ += bIterator.next();
        }

        return summ;
    }

    public static void main(String[] args) {
        Comparator<Long> desc = new Comparator<Long>() {
            @Override
            public int compare(Long a, Long b) {
                return (int) (b - a);
            }
        };

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        if (n > 1) {
            List<Long> odd = new LinkedList<>();
            List<Long> even = new LinkedList<>();

            while (n-- > 0) {
                long next = scanner.nextLong();

                if (next % 2 == 0) {
                    odd.add(next);
                } else {
                    even.add(next);
                }
            }

            Collections.sort(odd, desc);
            Collections.sort(even, desc);

            long aSumm = sum(odd, even);
            long bSumm = sum(even, odd);

            System.out.println(Math.min(aSumm, bSumm));
        } else {
            System.out.println(0);
        }
        scanner.close();
    }
    
}

