from sys import stdin,stdout
get=stdin.readline;put=stdout.write
n,a=int(get()),list(map(int,get().split()));e=[];o=[]
for i in a:
	if i%2:o.append(i)
	else:e.append(i)
m=min(len(o),len(e))
o=sum(sorted(o)[::-1][m+1:]);e=sum(sorted(e)[::-1][m+1:])
put(str(e+o if e+o else 0))