
n = int(input())
l = [int(x) for x in input().split()]

l1 = []
l2 = []

for i in l:
	if i % 2 == 1:
		l1.append(i)
	else:
		l2.append(i)

l1.sort()
l2.sort()

l1.reverse()
l2.reverse()

if len(l1) == len(l2):
	for i in range(len(l2)):
		del l1[0]
		del l2[0]
elif len(l1) > len(l2):
	for i in range(len(l2)):
		del l1[0]
		del l2[0]
	del l1[0]
else:
	for i in range(len(l1)):
		del l1[0]
		del l2[0]
	del l2[0]

print(sum(l1)+sum(l2))