n = int(input())

arr = list(map(int, input().split()))
odd = sorted(filter(lambda x: x % 2 != 0, arr))
even = sorted(filter(lambda x: x % 2 == 0, arr))

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

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