
if __name__ == '__main__':
	n = int(input())
	arr = list(map(int, input().split()))
	odds = []
	evens = []
	for num in arr:
		if num % 2 == 0:
			evens.append(num)
		else:
			odds.append(num)
	odds.sort()
	evens.sort()
	result = 0
	if len(odds) > len(evens) + 1:
		result = sum(odds[:len(odds) - len(evens) - 1])
	elif len(evens) > len(odds) + 1:
		result = sum(evens[:len(evens) - len(odds) - 1])
	print(result)
