# cook your dish here
n=int(input())
a=list(map(int,input().split()))
ao=[]
ae=[]
for i in a:
    if i%2:ao.append(i)
    else:ae.append(i)
co=len(ao)
ce=len(ae)
if abs(co-ce)<2:ans=0
elif co>ce:
    d=co-(ce+1)
    ao.sort()
    ans=sum(ao[:d])
else:
    d=ce-(co+1)
    ae.sort()
    ans=sum(ae[:d])
print(ans)