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

odd = sorted([i for i in a if i % 2 == 1], reverse=True)
even = sorted([i for i in a if i % 2 == 0], reverse=True)

state = None
if len(odd) > len(even):
    state = 1
else:
    state = 0

for i in a:
    if state == 1:
        if not odd:
            break
        odd.pop(0)
        state = 0
    else:
        if not even:
            break
        even.pop(0)
        state = 1

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