n = int(raw_input())
arr = map(int, raw_input().split())

odds = []
evens = []
for num in arr:
	if num % 2 == 0: evens.append(num)
	else: odds.append(num)

odds.sort()
evens.sort()
i = len(odds)-1
j = len(evens)-1
if len(odds) > len(evens): 
	odds = odds[:i]
	last_parity = 0
else: 
	evens = evens[:j]
	last_parity = 1

while i > -1 or j > -1:
	if last_parity and j == -1: break
	elif not last_parity and i == -1: break
	
	if last_parity:
		evens = evens[:j]
		last_parity = 0
		j -= 1
	else:
		odds = odds[:i]
		last_parity = 1
		i -= 1
		
print (sum(odds) + sum(evens))
