t=int(input())
l=list(map(int,input().split()))
x=[]
y=[]
for i in l:
    if(i%2==0):
        x.append(i)
    else:
        y.append(i)
x.sort(reverse=True)
y.sort(reverse=True)
if((len(x)==len(y)) or ((len(x)-1)==len(y)) or ((len(x)+1)==len(y))):
    print("0")
elif(len(x)>len(y)):
    print(sum(x[len(y)+1:len(x)]))
else:
    print(sum(y[len(x)+1:len(y)]))
