import java.util.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;
 
public class temp {
	
void solve() throws IOException
    {
       FastReader sc = new FastReader();
       int n = sc.nextInt();
       ArrayList<Integer> e = new ArrayList<>();
       ArrayList<Integer> o = new ArrayList<>();
       
       for(int i=0;i<n;i++)
       {
    	   int x = sc.nextInt();
    	   if(x%2==0)
    		   e.add(x);
    	   else
    		   o.add(x);
       }
       
       e.sort(null);
       o.sort(null);
       
       int min = Math.min(e.size(),o.size());
       int max = Math.max(e.size(),o.size());
       
       if(min==max)
    	   System.out.println(0);
       else
       {
	       int ans = 0;
	       for(int i=0;i<(e.size()==max ? e.size()-min-1 : e.size() - min);i++)
	    	   ans+=e.get(i);
	       for(int i=0;i<(o.size()==max ? o.size()-min-1 : o.size() - min);i++)
	    	   ans+=o.get(i);
	       
	       System.out.println(ans);
       }
   }
    
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        new temp().solve();
    }
   
    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;
        }
    }
 
}  