x=input()
l=map(int,raw_input().split(' '))
even_list=[]
odd_list=[]
for i in l:
  if i%2==0:
      even_list.append(i)
  else:
      odd_list.append(i)
even_list.sort(reverse=1)
odd_list.sort(reverse=1)
if (len(even_list)-len(odd_list)>1):
    print sum(even_list[(len(even_list)-len(odd_list)-1):]) 
elif (len(odd_list)-len(even_list)>1):
    print sum(odd_list[(len(odd_list)-len(even_list)-1):])
else:
    print "0" 
