n=int(input())
l=list(map(int,input().split()))
el=[]
ol=[]
ec=0
oc=0
for i in range(n):
    if l[i]&1==0:
        el.append(l[i])
        ec+=1 
    else:
        ol.append(l[i])
        oc+=1
el.sort()
ol.sort()
if ec==oc or ec==(oc+1) or oc==(ec+1):
    print(0)
else:
    
    res=0
    #print(ec,oc)
    if oc>ec:
        res=sum(ol[:(oc-(ec+1))])
    else:
        res=sum(el[:(ec-(oc+1))])
    print(res)
    