n=int(input())
l=list(map(int,input().split()))
p=[]
k=[]
l.sort()
for i in range(n):
	if l[i]%2==0:
		p.append(l[i])
	else:
		k.append(l[i])
r=len(p)
t=len(k)
if r>t:
	s=0
	for i in range(1,r-t):
		s+=p[i-1]
	print(s)
else:
	s=0
	for i in range(1,t-r):
		s+=k[i-1]
	print(s)