t=int(input())
l=list(map(int,input().split()))
asum=sum(l)
ev=[]
od=[]
eve,odd=0,0
for i in l:
    if(i%2==0):
        ev.append(i)
        eve+=1
    else:
        od.append(i)
        odd+=1
suml=0
ev=sorted(ev,reverse=True)
od=sorted(od,reverse=True)
minl = min(eve,odd)
for i in range(minl):
    suml+=ev[i]+od[i]
if(odd>eve and odd!=eve):
    suml+=od[minl]
elif(odd<eve and odd!=eve):
    suml+=ev[minl]
print(asum-suml)