n=int(input())
a=list(map(int,input().strip().split(' ')))
c1=0
c2=0
b=[]
c=[]
sum=0
for j in a:
    if j%2==0:
        c1+=1
        b.append(j)
    else:
        c2+=1
        c.append(j)

if c1==c2:
    sum=0
elif c1>c2:
    c1-=1
    b.sort()
    for k in range(c1-c2):
        sum+=b[k]
elif c2>c1:
    c2-=1
    c.sort()
    for k in range(c2-c1):
        sum+=c[k]
print (sum)
        
