n=int(input());l=list(map(int,input().split()));odd=[];even=[]
for x in l:
	if x%2:odd.append(x)
	else:even.append(x)
odd.sort();even.sort()
while len(odd) and len(even):odd.pop();even.pop()
if len(odd):odd.pop()
if len(even):even.pop()
print(sum(odd)+sum(even))