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 (abs(len(odd_list)-len(even_list))<=1):
    print "0"
elif (len(odd_list)<len(even_list)): 
    print sum(even_list[len(odd_list)+1:])
else:
    print sum(odd_list[len(even_list)+1:])  
  
