n = int(input())

a = list(map(int, input().split()))


ca = []
n = []

for c in a:
	if c % 2 == 0:
		ca.append(c)
	else:
		n.append(c)



ca.sort()
n.sort()

x = len(ca)
y = len(n)
if abs(x - y) <= 1:
	print(0)
elif x > y:
	s = 0
	for i in range(x - y - 1):
		s += ca[i]
	print(s)
else:
	s = 0
	for i in range(y - x - 1):
		s += n[i]
	print(s)
