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

evens = sorted([x for x in arr if x % 2 == 0], reverse=True)
odds = sorted([x for x in arr if x % 2 == 1], reverse=True)

if len(evens) == len(odds):
    print(0)
elif len(evens) > len(odds):
    print(sum(evens[len(odds)+1:]))
else:
    print(sum(odds[len(evens) + 1:]))
