n = int(input())
l = [*map(int, input().split())]
e = [x for x in l if x & 1]
o = [x for x in l if not (x & 1)]
a, b = len(e), len(o)
e.sort()
o.sort()
res = 0
if a < b:
    res = sum(o[:b - a - 1])
if b < a:
    res = sum(e[:a - b - 1])
print(res)