n=int(input())
l=list(map(int,input().split()))
e=[]
o=[]
for i in range(0,n):
	if l[i]%2==0:
		e.append(l[i])
	else:
		o.append(l[i])
e.sort()
o.sort()
if len(e)>len(o):
	n=len(o)
	if n!=0:
		del e[-n:]
	if len(e)>1:
		e.pop()
		print(sum(e))
	else:
		print(0)
else:
	n=len(e)
	if n!=0:
		del o[-n:]
	if len(o)>1:
		o.pop()
		print(sum(o))
	else:
		print(0)

