n = int(input())
s = [int(x) for x in input().split()]
odds = [x for x in s if x % 2]
evens = [x for x in s if x % 2 == 0]
odds.sort()
evens.sort()
if len(odds) - len(evens) >= 2:
    print(sum(odds[:-len(evens)-1]))
elif len(evens) - len(odds) >= 2:
    print(sum(evens[:-len(odds)-1]))
else:
    print(0)