n=int(input())
l=list(map(int,input().split()))
even=[]
odd=[]
l.sort()
for s in l:
    if(s&1 ==1):
        odd.append(s)
    else:
        even.append(s)
if(len(odd)==len(even)):
    print(0)
elif(len(odd)>len(even)):
    print(sum(odd[:len(odd)-len(even)-1]))
else:
    print(sum(even[:len(even)-len(odd)-1]))