n=int(input())
l=list(map(int,input().split()))
e=[]
o=[]
for i in l:
    if i%2:
        o.append(i)
    else:
        e.append(i)
a=len(e)
b=len(o)
e.sort()
o.sort()
if a-b==0:
    print(0)
elif b-a>0:
    print(sum(o[:b-a-1]))
else:
    print(sum(e[:a-b-1]))
    
    