n = int(input())
l = [int(x) for x in input().split()]
p, q = [], []
g = sum(l)

for i in l:
    if i % 2 == 0:
        p.append(i)
    else:
        q.append(i)

p.sort(reverse = True), q.sort(reverse = True)
k = min(len(p), len(q))
g -= (sum(p[:k])+sum(q[:k]))

if g != 0:
    if len(p) > len(q):
        print(g-p[k])
    else:
        print(g-q[k])
else:
    print(g)             