#Parity Alternated Deletions
n = int(input())
li = list(map(int,input().split()))
li1,li2 = [],[]
c1,c2 = 0,0
for i in li:
    if i%2==0:
        li1.append(i)
        c1+=1
    else:
        li2.append(i)
        c2+=1
if c1>c2:
    li1.sort()
    print(sum(li1[:c1-c2-1]))
elif c2>c1:
    li2.sort()
    print(sum(li2[:c2-c1-1]))
else:
    print('0')