N = int(input())
ITEMS = [int(item) for item in input().split()]

ODDS = [item for item in ITEMS if item % 2 != 0]
EVENS = [item for item in ITEMS if item % 2 == 0]

if len(EVENS) > len(ODDS):
    for _ in range(len(ODDS) + 1):
        EVENS.remove(max(EVENS))
    print(sum(EVENS))
elif len(EVENS) < len(ODDS):
    for _ in range(len(EVENS) + 1):
        ODDS.remove(max(ODDS))
    print(sum(ODDS))
else:
    print("0")
