#B
n = int(input())
a = list(map(int, input().split()))
odd = []
even = []
for i in a:
    if i % 2 == 1:
        odd.append(i)
    else:
        even.append(i)
odd.sort()
even.sort()
index = abs(len(odd) - len(even))
sum = 0
if index == 0 or index == 1:
    pass
else:
    if len(odd) > len(even):
        for i in range(index - 1):
            sum += odd[i]
    else:
        for i in range(index - 1):
            sum += even[i]
print(sum)
