n = int(input())
a = list(map(int, input().split()))
ev = sorted(list(filter(lambda x: x % 2 == 0, a)))
od = sorted(list(filter(lambda x: x % 2 != 0, a)))

f = len(od) - len(ev)

if f > 0:
    print(sum(od[0:f-1]))
elif f < 0:
    print(sum(ev[0:abs(f)-1]))
else:
    print(0)