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