n = int(input())
lis = list(map(int,input().split()))
e=[]
o=[]
for i in lis:
    if i%2==0:
        e.append(i)
    else:
        o.append(i)
le=len(e)
lo=len(o)
e=e+[0]
o=o+[0]
e.sort(reverse=True)
o.sort(reverse=True)
k=min(lo,le)
i=0
#print(o,e,i)
while i<k:
    e[i]=0
    o[i]=0
    i+=1
m=max(e[i],o[i])    
print(sum(e)+sum(o)-m)    
                