n = int(input())
a = list(map(int, input().split(' ')))

odd = sorted(filter(lambda x: x % 2 == 1, a))
even = sorted(filter(lambda x: x % 2 == 0, a))

if len(odd) > len(even):
    odd.pop()
elif len(even) > len(odd):
    even.pop()

while len(odd) > 0 and len(even) > 0:
    odd.pop()
    even.pop()

print(sum(odd) + sum(even))