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
ind = min(len(odds), len(evens))*2
if len(odds) != len(evens):
    ind +=1
for i in range(ind, a):
    k += elements[i]
print(k)