import sys
# sys.stdin = open('input.txt','r')
# sys.stdout = open('output.txt','w')
input = lambda:sys.stdin.readline().strip()
li = lambda:list(map(int,input().split()))
I = lambda: int(input())
n = I()
l =li()
l.sort()
odd = []
even =[]
for i in l:
	if i%2:
		odd.append(i)
	else:
		even.append(i)
o = len(odd)
e =len(even)
if o==e or o+1==e or o==e+1:
	print(0)
else:
	if o>e:
		odd=odd[:o-e-1]
		print(sum(odd))
	else:
		even=even[:e-o-1]
		print(sum(even))