input()
data = input().split()
evens = []
odds = []
for p in data:
    q = int(p)
    if q % 2 ==0:
        evens.append(q)
    else:
        odds.append(q)
odds.sort()
evens.sort()
if abs(len(evens) - len(odds)) < 2:
    print('0')
else:
    if len(evens) < len(odds):
        # sm = sum(evens)
        sm = sum(odds[:len(odds) - len(evens) - 1])
    else:
        sm = sum(evens[:len(evens) - len(odds) - 1])
    print(sm)