import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class JavaApplication180 {

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt()
        {
            return Integer.parseInt(next());
        }
        long nextLong()
        {
            return Long.parseLong(next());
        }
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        //int[] a = new int[n];
        List<Integer> oddNumbers = new ArrayList<>();
        List<Integer> evenNumbers = new ArrayList<>();
        int evenCount = 0 , oddCount=0 ;
        int sum = 0 ; 
        for ( int i = 0 ; i < n ; i ++)
        {
            int x= sc.nextInt();
            if (x %2 == 0 ) {
                evenNumbers.add(x); evenCount++;
            }
            else {
                oddNumbers.add(x); oddCount++;
            }    
        }
        
        Collections.sort(oddNumbers,Collections.reverseOrder());
        Collections.sort(evenNumbers,Collections.reverseOrder());
        
        if(evenCount == oddCount){
            System.out.println("0"); return;
        } 
        if (evenCount+1 == oddCount){
            System.out.println("0"); return;
        }
        else if (oddCount+1 == evenCount){
            System.out.println("0"); return;
        }
        
        else if (evenCount < oddCount) { 
            for ( int i =evenCount+1 ; i <oddCount ; i++)
                sum+= oddNumbers.get(i);
            
            System.out.println(sum);
            return;
        }
        else if (evenCount > oddCount) {
            for ( int i =oddCount+1 ; i <evenCount ; i++)
                sum+= evenNumbers.get(i);
            
            System.out.println(sum);
            return;
        }
        
    }
}
