import math
input()
inlist = map(int,input().split())
chet = list()
nechet = list()
for i in inlist:
	if i%2==0:
		chet.append(i)
	else:
		nechet.append(i)
if math.fabs(len(chet)-len(nechet))<=1:
	print('0')
else:
	if len(chet) > len(nechet):
		d = len(chet)-len(nechet)
		chet.sort()
		print(str(sum(chet[0:d-1])))
	else:
		d = len(nechet)-len(chet)
		nechet.sort()
		print(str(sum(nechet[0:d-1])))