n, l = int(input()), list(map(int, input().split()))
odds, evens = [], []
for i in l:
    if i % 2:
        odds.append(i)
    else:
        evens.append(i)

odds.sort()
evens.sort()

if len(odds) > len(evens):
    print(sum(odds[ : len(odds) - len(evens) - 1]))
elif len(evens) > len(odds):
    print(sum(evens[ : len(evens) - len(odds) - 1]))
else:
    print(0)
