n = int(raw_input())

x = list(map(int, raw_input().split()))
x.sort()
c_odd = 0
c_even = 0
for i in x:
	if i%2 == 0:
		c_even += 1
	else:
		c_odd += 1

j = min(c_even,c_odd)
if j==0:
	print sum(x[:-1])
	exit()
if c_odd > c_even:
	c_odd -= c_even
	c_odd -= 1
	ans = 0
	for i in x:
		if c_odd <= 0:
			print ans
			break
		if i%2 == 1:
			ans += i
			c_odd -=1
else:
	c_even -= c_odd
	c_even -= 1
	ans  =0
	for i in x:
		if c_even <= 0:
			print ans
			break
		if i%2 == 0:
			ans += i
			c_even -= 1

