n=int(input())
l=list(map(int, input().split()))
l1=[]
l2=[]

for i in range(n):
	if(l[i]%2==1):
		l1.append(l[i])
	else:
		l2.append(l[i])
		
def f(x, y):
	m=len(x)
	n=len(y)
	k=m-n-1
	if(k>=1):
		x.sort()
		tmp=0
		for i in range(k):
			tmp+=x[i]
		return tmp
	else:
		return 0
		
if(len(l1)>len(l2)):
	print(f(l1, l2))
else:
	print(f(l2, l1))

