n=input()
odd=[]
even=[]
oc=ec=0
a=map(int,raw_input().split())
for i in a:
    if i%2==0:
        ec+=1
        even.append(i)
    else:
        oc+=1
        odd.append(i)
odd.sort()
even.sort()
if ec==oc or ec==oc+1 or oc==ec+1:
    print 0
else:
    if oc>ec:
        print sum(odd[:oc-ec-1])
    else:
        print sum(even[:ec-oc-1])