

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;


public class JavaApplication2 {
  
        
 
       public static void main(String[] args) {
           Scanner ss=new Scanner(System.in);
           int n=ss.nextInt();
            int[] arr= new int[n];
            int odd=0;
            int even=0;
            int sum=0;
            for (int i = 0; i < n; i++) {
                arr[i]=ss.nextInt();
                if(arr[i]%2==0)
                    even++;
                else odd++;
           }
            Arrays.sort(arr);
            if(odd==even)
                System.out.print(sum);
            else if(Math.abs(odd-even)==1)
                System.out.print(sum);
            
            else{
                if(even>odd+1)
                {
                   even=even-odd-1;
                    for (int i = 0; i < even; i++) {
                        if(arr[i]%2==0)
                            sum+=arr[i];
                        else even++;
                        
                    }
                }
                else{
                     odd=odd-even-1;
                    for (int i = 0; i < odd; i++) {
                        if(arr[i]%2==1)
                            sum+=arr[i];
                        else odd++;
                        
                    }
                    
                    
                }
                
           System.out.print(sum);
               
           }
        
             
                     
                     
                     
                 
                 
                
                     
                 
                    
          
           
        
  
       
        
     
        
            
       
       
        
        
        
        
           
          


        
    }

   
}
