n = int(input())
l = [int(x) for x in input().split()]
l.sort()

evens = []
evencount = 0
odds = []
oddcount = 0
for item in l:
    if item % 2 == 0:
        evencount += 1
        evens.append(item)
    else:
        oddcount += 1
        odds.append(item)
if max(evencount - oddcount,oddcount - evencount) <= 1:
    print(0)
elif evencount >= oddcount:
    r = evencount - oddcount - 1
    print(sum(evens[:r]))
else:
    r = oddcount - evencount - 1
    print(sum(odds[:r]))
