n =  int(raw_input())

ar = map(int, raw_input().split())

ar_par = []
ar_impar = []

for k in xrange(n):
	if  ar[k] % 2 == 0:
		ar_par.append(ar[k])
	else:
		ar_impar.append(ar[k])

troll_par = False
troll_impar = False

ar_impar.sort()
ar_par.sort()


if len(ar_impar) > len(ar_par):
	troll_impar = True
elif len(ar_impar) < len(ar_par):
	troll_par = True
	
while( len(ar_impar) != 0 and len(ar_par) != 0):
	
	ar_impar.pop(-1)
	ar_par.pop(-1)

if troll_impar:
	ar_impar.pop(-1)
elif troll_par:
	ar_par.pop(-1)


print sum(ar_impar) + sum(ar_par)
