n=int(input())
a=list(map(int,input().split()))
ev=[]
od=[]
e,o=0,0	
for i in range(len(a)):
	if a[i]%2==0:
		ev.append(a[i])
		e+=1
	else:
		od.append(a[i])
		o+=1
x=min(e,o)
ev.sort(reverse=True)
od.sort(reverse=True)
if e>o:
	print(sum(ev[x+1:len(ev)]))
elif o>e:
	print(sum(od[x+1:len(od)]))
else:
	print(0)