n=int(input())
l=list(map(int,input().split()))
l1=[]
l2=[]
l.sort()
for i in l:
    if i%2==0:
        l1.append(i)
    else:
        l2.append(i)
mx=max(l)
d=0
if len(l1)>len(l2):
    d=0
else:
    d=1
#print(l1,l2)    
for i in range(n):
    if d%2==0:
        if not l1:
            break
        del l1[-1]
    else:
        if not l2:
            break
        del l2[-1]
    d+=1    
print(sum(l1)+sum(l2))        