n=input()
o=0
e=0 
odd=[]
even=[]
a=map(int,raw_input().split()) 
for i in range(len(a)) :
  if a[i]%2==0 :
    e+=1 
    even.append(a[i])
  else :
    o+=1 
    odd.append(a[i]) 
odd.sort()
even.sort()

if e==o or e+1==o or o+1==e : 
  print 0 
elif o!=0 and e!=0 and o>e :
  d=o-e 
  print sum(odd[:d])
elif o!=0 and e!=0 and e>o:
  d=e-o 
  print sum(even[:d])
elif e==len(a) :
  print(sum(even[:n-1]))
elif o==len(a) :
  print(sum(odd[:n-1]))