n=int(input())
alist=list(map(int,input().split()))
blist=[]
clist=[]
for i in alist:
    if i%2==1:
        blist.append(i)
    else:
        clist.append(i)
b=len(blist)
c=len(clist)
blist.sort(reverse=True)
clist.sort(reverse=True)
if abs(b-c)<=1:
    print("0")
else:
    if b>c:
        blist=blist[c+1::]
        print(sum(blist))
    elif c>b:
        clist=clist[b+1::]
        print(sum(clist))
        
