n = int(input())
a, b = [], []
for el in map(int, input().split()):
    if el % 2:
        a.append(el)
    else:
        b.append(el)

if len(a) < len(b):
    a, b = b, a

if len(a) <= len(b) + 1:
    print(0)
else:
    print(sum(a[len(b) + 1:]))
