n = int(input())
a = list(map(int,input().split()))
a.sort()
a.reverse()
x=[]
y=[]
ans=0
for i in a:
	if i%2==0:
		x.append(i)
	else:
		y.append(i)
xc=len(x)
yc=len(y)
if xc==min(xc,yc):
	for i in range(xc+1,len(y)):
		ans+=y[i]
else:
	for i in range(yc+1,len(x)):
		ans+=x[i]
print(ans)
