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