n = int(input())
a = [int(x) for x in input().split()]
odds = sorted([x for x in a if x % 2])
evens = sorted([x for x in a if x % 2 == 0])
diff = len(odds) - len(evens)
if diff == 0:
    print(0)
elif diff < 0:
    diff += 1
    print(sum(evens[:-diff]))
else:
    diff -= 1
    print(sum(odds[:diff]))
