n=int(input())
a=list(map(int,input().split()))
even=[]
odd=[]
for i in range(len(a)):
	if(a[i]%2==0):
		even.append(a[i])
	else:
		odd.append(a[i])
even.sort(reverse=True)
odd.sort(reverse=True)
if(abs(len(even)-len(odd))<=1):
	print(0)
else:
	k=min(len(even),len(odd))
	print(sum(even[k+1:])+sum(odd[k+1:]))