input()
A = list(map(int, input().split()))
A.sort()
even_nums = []
odd_nums = []

for num in A:
	if num % 2 == 0:
		even_nums.append(num)
	else:
		odd_nums.append(num)

x = len(even_nums) - len(odd_nums)

if x == 0 or x == 1 or x == -1:
	print(0)

else:
	if x > 0:
		print(sum(even_nums[0:x - 1]))
	elif x < 0:
		print(sum(odd_nums[0:x - 1]))
