x=int(input())
y=input().split(" ")
e=[]
E=0
o=[]
O=0
s=0
for i in range(len(y)):
    if int(y[i])%2==0:
        e.append(int(y[i]))
        E+=1
    else:
        o.append(int(y[i]))
        O+=1
e=sorted(e)
o=sorted(o)

for i in range(abs(E-O)-1):
    if E>O:
        s+=e[i]
    elif O>E:
        s+=o[i]
print(s)