a = int(input())
arr = list(map(int ,input().split()))
even=[]
odd=[]
ans=0
for x in arr:
	if x%2==0:
		even.append(x)
	else:
		odd.append(x)

even = sorted(even)
odd = sorted(odd)	
diff = int(abs(len(even)-len(odd))) 		
if diff > 1:
	if len(even)<len(odd):
		for i in range(diff-1):
			ans+=odd[i]
	else:
		for i in range(diff-1):
			ans+=even[i]	

print(ans)