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