input()

nums = [int(i) for i in input().split(' ')]
odds = []
evens = []
for i in nums:
    if i % 2 == 0:
        evens.append(i)
    else:
        odds.append(i)
odds.sort()
evens.sort()
l = len(odds) - len(evens)
if l > 1:
    print(sum(odds[:l - 1]))
elif l < -1:
    print(sum(evens[:-l - 1]))
else:
    print(0)
