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