I=lambda: list(map(int,input().split()))
n,=I()
l=I()
o=[]
e=[]
x=0
y=0
for i in l:
    if i%2:
        o.append(i)
        x+=1
    else:
        e.append(i)
        y+=1
e.sort()
o.sort()
if abs(x-y)<=1:
    print(0)
else:
    if x>y:
        print(sum(o[:abs(y-x)-1]))
    else:
        print(sum(e[:abs(y-x)-1]))
        