from sys import*
input()
q = list(map(int, input().split()))
odd = sorted(filter(lambda x: x % 2 == 0, q))[::-1]
even = sorted(filter(lambda x: x % 2 == 1, q))[::-1]
if(len(odd) - len(even) > 1):
    print( sum( odd[len(even) + 1 : ] ) )
elif(len(odd) - len(even) < -1):
    print( sum( even[len(odd) + 1 : ] ) )
else:
    print(0)
