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

evens = sorted([x for x in arr if x % 2 == 0])
odds = sorted([x for x in arr if x % 2 == 1])
diff = abs(len(evens) - len(odds))
if diff >= 1:
    diff -= 1

if len(evens) > len(odds):
    print(sum(evens[:diff]))
else:
    print(sum(odds[:diff]))
