import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.Arrays;

public class Main{

    public static void main(String[] args)throws IOException{
    	br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
	int n = nextInt();
	int vp[] = new int[n];
	int vi[] = new int[n];
	Arrays.fill(vp,-1);
	Arrays.fill(vi,-1);
	int x,im = 0, p=0;
	for(int i = 0; i<n;i++){
	    x = nextInt();
	    if(x%2==0){
		vp[p] = x;
		p++;
	    }else{
		vi[im] = x;
		im++;
	    }
	}
	Arrays.sort(vp);
	Arrays.sort(vi);
	if(Math.abs(im-p)==1 || Math.abs(im-p)==0){
	    out.println(0);
	}else{
	    int res = 0;
	    if(p>im){
		int me = Math.min(p,im)+1;
		for(int i = n-1-me; i>=0;i--){
		    if(vp[i]!=-1){
			res+=vp[i];
		    }else{
			break;
		    }
		}
	    }else{
		int me = Math.min(p,im)+1;
		for(int i = n-1-me; i>=0;i--){
		    if(vi[i]!=-1){
			res+=vi[i];
		    }else{
			break;
		    }
		}
	    }
	    out.println(res);
	}
	out.close();
    }
     
    static BufferedReader br;
    static StringTokenizer st = new StringTokenizer("");
    static String next()throws IOException{
    	while(!st.hasMoreTokens()){
    	    st = new StringTokenizer(br.readLine());
    	}
    	return st.nextToken();
    }
    static int nextInt()throws IOException{
    	return Integer.parseInt(next());
    }
    static long nextLong()throws IOException{
	return Long.parseLong(next());
    }
}
