n = int(input())
A = sorted(list(map(int, input().split())))
anso = 0
anse = 0
for i in A:
	if i % 2 == 0:
		anse += 1
	else:
		anso += 1
k = 0
ans = 0
t = 0
if anse > anso:
	while k < n and t < anse - anso - 1:
		if A[k] % 2 == 0:
			ans += A[k]
			t += 1 
		k += 1
else:
	while k < n and t < anso - anse - 1:
		if A[k] % 2 == 1:
			ans += A[k]
			t += 1 
		k += 1
print(ans)
