N = int(input())
evens = []
odds = []
s = input()
s = s.split()
integer = [int(c) for c in s]
for n in integer:
    if n%2 == 0:
        evens.append(n)
    else:
        odds.append(n)

evens = sorted(evens)
odds = sorted(odds)

ei = oi = 0

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