n = int(str(input()).strip())
arr = [int(x) for x in str(input()).strip().split(' ')]
o = []
e = []
for a in arr:
    if a % 2 == 0:
        e.append(a)
    else:
        o.append(a)
o = list(sorted(o, reverse=True))
e = list(sorted(e, reverse=True))
# print(o, e)
minoe = min(len(o), len(e))
co = sum(o[minoe + 1:]) + sum(e[minoe:])
ce = sum(e[minoe + 1:]) + sum(o[minoe:])
print(min(co, ce))