N = int(input())
k = sorted([int(i) for i in input().split()])
odd = list(filter(lambda x: x % 2 == 0, k))
even = list(filter(lambda x: x % 2 == 1, k))
sum = 0
if abs(len(odd) - len(even)) < 2:
    pass
elif len(even) > len(odd):
    for i in range(len(even) - len(odd) - 1):
        sum += even[i]
else:
    for i in range(len(odd) - len(even) - 1):
        sum += odd[i]
print(sum)