n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
a.reverse()
odd = 0
even = 0
b = []
c = []
for i in range(len(a)):
    if a[i]%2 == 1:
        b.append(a[i])
        odd+=1
    else:
        even+=1
        c.append(a[i])
s = 0
t = 0
if odd > even:
    i = odd - (even+1)
    s = sum(b[odd-i:])
    s+=sum(c[even:])
elif even > odd:
    i = even - (odd+1)
    s = sum(b[odd:])
    s+=sum(c[even-i:])
else:
    s = sum(b[odd:])
    s += sum(c[even:])

print(s)