import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.nio.Buffer;
import java.util.*;

public class Pair {

    static class FastReader {
        private BufferedReader br;
        private StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static int fact(int n){
        int fact =1;
        for(int i=1;i<=n;i++){
            fact = fact*i;
        }
        return fact;
    }
    public static long Deletion(int[]arr){
        ArrayList<Integer> even = new ArrayList<>(),odd = new ArrayList<>();

        for(int i=0;i<arr.length;i++){
            if((arr[i]&1)==1){
                odd.add(arr[i]);
            }
            else{
                even.add(arr[i]);
            }
        }
        Collections.sort(even);
        Collections.sort(odd);
        if(Math.abs(even.size()-odd.size())<=1){
            return 0L;
        }
        int sum=0;
        if(even.size()>odd.size()){
            for(int i=odd.size()+1;i<even.size();i++){
                sum+=even.get(i);
            }
        }
        else{
            for(int i=even.size()+1;i<even.size();i++){
                sum+=odd.get(i);
            }
        }
        return sum;

    }
    public static void main (String[] args) throws Exception{
        try{
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[]arr = new int[n];
            for(int i=0;i<arr.length;i++){
                arr[i] = sc.nextInt();
            }
            System.out.println(Deletion(arr));



        }
        catch(Exception e){

        }
    }
}