n = int(input())
a = [int(item) for item in input().split()]
a.sort()

o = [x for x in a if x % 2][::-1]
e = [x for x in a if x % 2 == 0][::-1]

l = min(len(o), len(e))
if len(o) < len(e):
    d = sum(o) + sum(e[:l + 1])
else:
    d = sum(e) + sum(o[:l + 1])
print(sum(a) - d)
