n = int(input().strip())
arr = list(map(int, input().strip().split()))
evens = []
odds = []
for i in arr:
	if i % 2 == 0:
		evens.append(i)
	else:
		odds.append(i)

le, lo = len(evens), len(odds)

if abs(le - lo) <= 1:
	print(0)
elif le > lo:
	evens.sort()
	print(sum(evens[:le-lo-1]))
else:
	odds.sort()
	print(sum(odds[:lo-le-1]))