n = int(input())
a = list(map(int,input().split()))
a = sorted(a,reverse=True)
even = []
odd = []
for i in a:
	if i%2==0:
		even.append(i)
	else:
		odd.append(i)
if len(odd)>len(even):
	if len(odd)-len(even)==1:
		print(0)
	else:
		print(sum(odd[len(even)+1:]))
elif len(even)>len(odd):
	if len(odd)-len(even)==-1:
		print(0)
	else:
		print(sum(even[len(odd)+1:]))
else:
	print(0)