n = int(input())
a = map(int, input().split())
odds = []
evens = []

for number in a:
    if number%2 == 0:
        evens.append(number)
    else:
        odds.append(number)
o = len(odds)
e = len(evens)
if (o - e) in [-1, 0, 1]:
    print(0)
else:
    if o > 0:
        odds.sort()
    if e > 0:
        evens.sort()
    if o > e:
        print(sum(odds[:(o-e-1)]))
    elif e > o:
        print(sum(evens[:(e-o-1)]))
