
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class ParityAlternatedDecisionsB implements Comparator<Integer>
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int i,ans=0;
        ArrayList<Integer> eve=new ArrayList<>();
        ArrayList<Integer> odd=new ArrayList<>();
        for(i=0;i<n;i++)
        {
            int a=sc.nextInt();
            if(a%2==1)
            {
                //System.out.println("Adding in Even parity"+a);
                eve.add(a);
            }
            else
            {
               // System.out.println("Adding in Odd parity "+a);
                odd.add(a);
            }
        }
        if(eve.size()==odd.size() || (Math.abs(eve.size()-odd.size())==1))
        {
            System.out.println("0");
        }
        else if(eve.size()>odd.size())
        {
            Collections.sort(eve,new ParityAlternatedDecisionsB());
            for(i=odd.size()+1;i<eve.size();i++)
            {
                ans+=eve.get(i);
            }
           // if(odd.size()!=0)
            {
                System.out.println(ans);
            }
            //else
            {
              //  System.out.println(ans-eve.get(odd.size()));
            }
        }
        else
        {
            Collections.sort(odd,new ParityAlternatedDecisionsB());
            for(i=eve.size()+1;i<odd.size();i++)
            {
                //System.out.println(odd.get(i)+" ");
                ans+=odd.get(i);
            }
            //if(eve.size()!=0)
            {
                System.out.println(ans);
            }
            //else
            {
              //  System.out.println(ans-odd.get(eve.size()));
            }
        }
    }
    public static int setbits(int n)
    {
        int cnt =0;
        while(n>0)
        {
            n&=n-1;
            cnt++;
        }
        return n%2==0?1:0;
    }

    @Override
    public int compare(Integer o1, Integer o2) {
        return o1<o2?1:-1;
    }
}
