import java.lang.*;
import java.util.*;
public class plmin {
    public static void main(String[] args) 
    {
      Scanner sc=new Scanner(System.in);
      int n=sc.nextInt(),t=0,sum=0,m=0,m1=0,e=0,o=0;
     // int even[]=new int[n],e=0;
      //int odd[]=new int[n],o=0;
      ArrayList<Integer> even=new ArrayList<Integer>();
      ArrayList<Integer> odd=new ArrayList<Integer>();
      for(int i=0;i<n;i++)
      {
         t=sc.nextInt();
         sum+=t;
          if(t%2==0)
              even.add(t);
              //even[e++]=t;
          else
              odd.add(t);
              //odd[o++]=t;
      }
      int e1=even.size()-1,o1=odd.size()-1;
      Collections.sort(even);
      Collections.sort(odd);
      int p=0;
      //System.out.println(even+" "+odd);
     // System.out.println(sum+" "+e1+" "+o1);
      while(1==1)
      {
          if(p==0)
          {
              if(e1==-1)
                  break;
              m+=even.get(e1--);
              p=1;
             // System.out.println(m+" "+e1+" "+o1);
          }
          else
          {
              if(o1==-1)
                  break;
          m+=odd.get(o1--);
          p=0;
        //  System.out.println(m+" "+e1+" "+o1);
          }
      }
      p=1;
      e1=even.size()-1;o1=odd.size()-1;
      while(1==1)
      {
          if(p==0)
          {
              if(e1==-1)
                  break;
              m1+=even.get(e1--);
              p=1;
             // System.out.println(m1+" "+e1+" "+o1);
          }
          else
          {
              if(o1==-1)
                  break;
          m1+=odd.get(o1--);
          p=0;
        //  System.out.println(m1+" "+e1+" "+o1);
          }
      }
      if(m>m1)
    sum=sum-m;
    else
    sum=sum-m1;
    System.out.println(sum);
    }   
}