n=int(input())

e=[]
o=[]
ans=0
dc=dict()
for i in input().split():
    a=int(i)
    if a%2==0:
        e.append(a)
    else:
        o.append(a)
    
if abs(len(e)-len(o))<=1:
    ans=0
else:
    d=len(e)-len(o)
    if d>0:
        b=sorted(e)
        for j in range(d-1):
            ans+=b[j]
    else:
        b=sorted(o)
        for j in range(-d-1):
            ans+=b[j]
    
#print(ans,e,o,b,d)
print(ans)