t=int(raw_input())
a=map(int,raw_input().split())
a=sorted(a)
e,o=0,0
for i in a:
    if i%2==0:
        e+=1
    else:
        o+=1
if abs(e-o)<2:
    print 0
else:
    s=0
    q=abs(e-o)-1
    if e>o:
        for i in range(t):
            if a[i]%2==0 and q>0:
                s+=a[i]
                q-=1
    else:
        for i in  range(t):
            if a[i]%2!=0 and q>0:
                s+=a[i]
                q-=1
    print s
        


