input()
a = [int(x) for x in input().split()]
o = [x for x in a if x % 2 == 1]
e = [x for x in a if x % 2 == 0]
o.sort()
e.sort()
k = min(len(o), len(e))
for _ in range(k):
    o.pop()
    e.pop()
if e and (not o or o[-1] < e[-1]):
    e.pop()
elif o:
    o.pop()
print(sum(e) + sum(o))
