n = int(input())
a = sorted(list(map(int,input().split())))
o = []
e = []
for i in a:
    if i%2==0:
        e.append(i)
    else:
        o.append(i)

o.sort()
e.sort()
if len(o)>=len(e):
    s = sum(o[0:max(len(o)-len(e)-1,0)])
else:
    s = sum(e[0:max(len(e)-len(o)-1,0)])
print(s)
    