n=input()
numbers=list(map(int,input().split()))
even=[i for i in numbers if i%2==0 and i != 0]
odd =[i for i in numbers if i%2!=0]
taken= min(len(even),len(odd))
even.sort(reverse=True)
odd.sort(reverse=True)
value = 0
if len(even) > len(odd):
    value += sum(even[taken+1:])
    value += sum(odd[taken:])
elif len(odd)>len(even):
    value += sum(odd[taken+1:])
    value += sum(even[taken:])
else:
    value += sum(sorted(numbers[2*taken+1:],reverse=True))
    

print(value)
