n=int(input());a=list(map(int,input().split()));ev=[];od=[]
for i in range(n):
    if a[i]%2==0:ev.append(a[i])
    else:od.append(a[i])
p=len(ev);q=len(od)
if p==q or p-q==1 or q-p==1:print(0)
else:
    s=min(p,q)
    if p==s:print(sum(sorted(od)[0:q-p-1]))
    else:print(sum(sorted(ev)[0:p-q-1]))