n=int(input())
a=list(map(int,input().split()))
odd=[]
even=[]
for i in a:
    if i%2==0:
        even.append(i)
    else:
        odd.append(i)
even_len=len(even)
odd_len=len(odd)
sum=0
if(odd_len-even_len in range(-1,2)):
    print(0)
else:
    diff=odd_len-even_len
    if diff>0:
        odd.sort()
        for j in range(diff-1):
            sum+=odd[j]
    else:
        diff=0-diff
        even.sort()
        for j in range(diff-1):
            sum+=even[j]
    print(sum)            
