n = input()
l = map(int, raw_input().split())
even, odd = [], []
for i in l:
	if i%2:
		odd.append(i)
	else:
		even.append(i)
odd.sort()
i = 0
even.sort()
if len(even) > len(odd):
	i = 1
while 1:
	if i == 0:
		if len(odd) > 0:
			odd.pop()
		else:
			break
	else:
		if len(even) > 0:
			even.pop()
		else:
			break
	i = 1 - i
odd.append(0)
even.append(0)
print sum(odd) + sum(even)