n = int(input())
a = list(map(int,input().split()))
a.sort()
ev =[];od = [];re =[]
for i in a:
    if(i%2==0):
        ev.append(i)
    else:
        od.append(i)

if len(ev)>len(od):
    re = ev[:len(ev)-1-len(od)]
elif len(ev)<len(od):
    re = od[:len(od)-1-len(ev)]
else:
    re = [0]

print(sum(re))