n = int(input())
s = list(map(int, input().split()))
s.sort(reverse = True)
summ = sum(s)
a1 = 0
a2 = 0
for i in range(n):
	if s[i] % 2:
		a1 += 1
	else:
		a2 += 1
if a1 == a2:
	print(0)
else:
	if a1 > a2:
		a1 = a2+1
	else:
		a2 = a1 + 1
	x = 0
	for i in range(n):
		if (s[i] % 2 and x < a1):
			x += 1
			summ -= s[i]
	x = 0
	for i in range(n):
		if (not(s[i] % 2) and x < a2):
			x += 1
			summ -= s[i]
	print(summ)
