n=int(input())
a=[int(i) for i  in input().split()]
e=[]
o=[]
for i in range(0,len(a)):
    if(a[i]%2==0):
        e.append(a[i])
    else:
        o.append(a[i])
if(abs(len(e)-len(o))<=1):
    print(0)
else:
    e=sorted(e)
    o=sorted(o)
    if(len(e)>len(o)):
        f=e[0:(len(e)-len(o))-1]
        print(sum(f))
    else:
        f=o[0:(len(o)-len(e))-1]
        print(sum(f))