n = int(input())
data = list(map(int, input().split()))
even = []
odd = []

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

le = len(even)
lo = len(odd)
even = sorted(even)
odd = sorted(odd)

if abs(le-lo) <= 1:
	print(0)
elif lo > le:
	x = (lo-le)-1
	print(sum(odd[:x]))
else:
	x = (le-lo)-1
	print(sum(even[:x]))