n = int(input())
a = [int(x) for x in input().split(' ')]
evens = [x for x in a if x % 2 == 0]
odds = [x for x in a if x % 2 == 1]
evens.sort()
odds.sort()

E = len(evens)
O = len(odds)

if E > O:
    ans = sum(evens[:-(O + 1)])
elif E == O:
    ans = 0
else:
    ans = sum(odds[:-(E + 1)])
print(ans)