n=int(input())
lst=[int(i) for i in input().split()]
lst.sort(reverse=True)
no=0
ne=0
for i in lst:
    if i%2==0:
        ne+=1
    else:
        no+=1
min1=min([ne,no])
min1=min1+1
no=0
ne=0
sum1=0
#print(min1)
for i in lst:
    if i%2==0 and ne<min1:
        ne+=1
    elif i%2==0:
        sum1=sum1+i
    if i%2!=0 and no<min1:
        no+=1
    elif i%2!=0:
        sum1=sum1+i
print(sum1)
