

n = int(input())
l = list(map(int, input().split()))


even = []
odd = []

for i in range(n):
	if l[i] % 2 == 0:
		even.append(l[i])
	else:
		odd.append(l[i])

even.sort(reverse = True)
odd.sort(reverse = True)

if len(even) == len(odd):
	print(0)
elif len(even) > len(odd):
	print(sum(even[len(odd) + 1:]))
else:
	print(sum(odd[len(even) + 1:]))