size = int(input())

array = list(map(int, input().split()))

evens = sorted([i for i in array if i % 2 == 0])[::-1]
odds = sorted([i for i in array if i % 2 != 0])[::-1]

deletions = min(len(evens) , len(odds))

evens = evens[deletions:]
odds = odds[deletions:]

if (len(odds) > 0) or (len(evens) > 0) :
    if (len(odds) > 0) :
        odds = odds[1:]
    if (len(evens) > 0) :
        evens = evens[1:]

print(sum(evens) + sum(odds))


    
