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=True)
odd_list.sort(reverse=True)
if (len(l)==1):
   print "0"
elif(len(l)==2):
   if (l[0]==l[1]):
       print l[0]
   elif (len(even_list)==len(odd_list)):
       print "0"
   elif((len(even_list)==2 and len(odd_list)==0) or ((len(even_list)==0) and len(odd_list)==2)):
       print min(l[0],l[1]) 
else:
    if len(even_list)>len(odd_list):
        if ((len(even_list)-len(odd_list)==0) or (len(even_list)-len(odd_list)==1)):
            print "0"
        elif (len(even_list)-len(odd_list)>1):
            for y in range(len(odd_list)):
               even_list.remove(even_list[y]) 
            print sum(even_list)                 
    else:
        if ((len(odd_list)-len(even_list)==0) or (len(odd_list)-len(even_list)==1)):
            print "0"
        elif (len(odd_list)-len(even_list)>1):
            for y in range(len(even_list)):
               odd_list.remove(odd_list[y])
            print sum(odd_list)
    
