n = int(input())
e, o = [], []
for i in map(int, input().split()):
    if i % 2 == 0:
        e.append(i)
    else:
        o.append(i)
se, so = len(e), len(o)
e.sort()
o.sort()
if se == so or abs(se - so) == 1:
    exit(print(0))
print(sum(e[:se - (so + 1)]) if min(se, so) == so else sum(o[:so - (se + 1)]))
