n = int(input())

a = list(map(int,input().split()))

even = []
odd = []

for num in a:
	if num%2 == 1: #num is odd
		odd.append(num)
	else:
		even.append(num)

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

if abs(le-lo) <= 1:
	print('0')
else:
	size = abs(le-lo) - 1
	if le > lo:
		m = sorted(even)
	else:
		m = sorted(odd)
	print(sum(m[:size]))