n=input()
l=map(int,raw_input().split())
c1,c2=0,0
for i in l:
    if i%2:
        c1+=1
    else:
        c2+=1
l.sort(reverse=True)
ans=0
if abs(c1-c2)<=1:
    print 0
    exit()
if c1>c2:
    for i in l:
        if c2<0 and i%2:
            ans+=i
            continue
        if i%2:
            c2-=1
        
else:
    for i in l:
        if c1<0 and not i%2:
            ans+=i
            continue
        if not i%2:
            c1-=1
print ans
