n = int(input())
Arr = sorted(list(map(int, input().split())))

evens = []
odds = []

for el in Arr:
    if el % 2 == 0:
        evens.append(el)
    else:
        odds.append(el)
evens.sort()
odds.sort()

i = 0

while evens and odds:
    if evens:
        evens.pop()
    if odds:
        odds.pop()

if evens:
    evens.pop()
if odds:
    odds.pop()

print(max(sum(evens), sum(odds)))
