a=int(input());o=[];e=[];n=0
for i in map(int,input().split()):
    if i%2:o+=[i];n+=1
    else:e+=[i]
z=a-n
if z>n:print(sum(sorted(e[n+1:],reverse=True)))
else:print(sum(sorted(o[z+1:],reverse=True)))
