n = int(input())
a = [int(j) for j in input().split()]
a.sort()

even = []
odd = []
for i in range(n):
	if a[i]%2 == 0:
		even += [a[i]]
	else:
		odd += [a[i]]

# print(even)
# print(odd)
if abs(len(even) - len(odd)) <= 1:
	print(0)
elif len(even) - len(odd) >= 1:
	print(sum(even[:len(even)-len(odd)-1]))
elif len(odd) - len(even) >= 1:
	print(sum(odd[:len(odd)-len(even)-1]))