a = int(input())
elements = list(map(int, input().split()))
elements.sort(reverse = True)
evens = []
odds = []

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

k=0
if len(odds) > len(evens)+1:
	print (sum(odds[len(evens)+1:]))
elif len(evens) > len(odds)+1:
	print (sum(evens[len(odds)+1:]))
else:
	print(0)