a = int(input())
s = [int(i) for i in input().split()]
h = sorted(filter(lambda x: x % 2 == 0, s))
p = sorted(filter(lambda x: x % 2 == 1, s))
if len(h) < len(p):
    h, p = p, h
h = h[len(p) + 1:]
print(sum(h))
