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)
z=0
a=0
sum=0
k=len(even_list)
q=len(odd_list)
if len(l)==1:
    print "0"
else:
    if (k==q or k-q==1 or q-k==(-1) or k-q==-1 or q-k==1):
        print "0"
    elif(k-q>1):
        z=q+1
        for j in range(z):
            even_list.pop(0)
        if z==1:
            sum=even_list[0]
            print sum
        else:
            for k in range(len(even_list)):
                sum+=even_list[k]
            print sum 
    elif(q-k>1):
        z=k+1
        for j in range(z):
            odd_list.pop(0)
        if z==1:
            sum=odd_list[0]
            print sum
        else:
            for k in range(len(odd_list)):
                sum+=odd_list[k]     
            print sum
 
 
