n = int(input())
l = list(map(int,input().split()))
l.sort()

o,e=[],[]
for i in l:
	if i%2!=0:
		o.append(i)
	else:
		e.append(i)

if len(o)==len(e):
	print(0)
elif len(o)>len(e):
	print(sum(o[:len(o)-len(e)-1]))
else:
	print(sum(e[:len(e)-len(o)-1]))