to = te= 0
n = int(input())
l = [*map(int,input().split())]
odd = []
even =[]
for i in l:
    if i%2 == 0:
        even.append(i)
        te+=1
    else:
        odd.append(i)
        to+=1
if to == te:
    print(0)
elif to > te:
    if to - 1 == te:
        print(0)
    else:
        odd.sort()
        print(sum(odd[:to-(te+1)]))
         
else:
    if te - 1 == to:
        print(0)
    else:
        even.sort()
        print(sum(even[:te-(to+1)]))
        