import sys


input = sys.stdin.readline


n = input().rstrip()
poly = list(map(int, input().split()))

odds = list()
evens = list()
for i in poly:
    if i%2 == 0:
        evens.append(i)
    else:
        odds.append(i)

l_o = len(odds)
l_e = len(evens)

if abs(len(odds) - len(evens)) <= 1:
    print(0)
else:
    while len(odds) != 0 and len(evens) != 0:
        if len(odds) < len(evens):
            evens.remove(max(evens))
            continue

        if len(odds) > len(evens):
            odds.remove(max(odds))
            continue

        if len(odds) == len(evens):
            if max(odds) > max(evens):
                odds.remove(max(odds))
                continue
            else:
                evens.remove(max(evens))
                continue
    
    if l_o == 0:
        print(sum(evens)-max(evens))
    elif l_e == 0:
        print(sum(odds)-max(odds))
    else:
        print(sum(odds) + sum(evens))
