import java.util.*;
import java.io.*;
public class Main {
	static int[] A;
	static int[] B;
	static int[] C;
	static int n;
	static int ans;
	public static void main(String[] args)throws IOException {
		// TODO Auto-generated method stub
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(in.readLine());
        n = Integer.parseInt(tokenizer.nextToken());
        C = new int[n];
        int o=0,e=0;
        StringTokenizer tokenizer1 = new StringTokenizer(in.readLine());
        for(int i=0;i<n;i++) {
        	C[i] = Integer.parseInt(tokenizer1.nextToken());
        	if(C[i]%2==0) {
        		e++;
        	}
        	else {
        		o++;
        	}
        }
        A = new int[e];
        B = new int[o];
        int cnt1=0,cnt2=0;
        for(int i=0;i<n;i++) {
        	if(C[i]%2==0) {
        		A[cnt1]=C[i];
        		cnt1++;
        	}
        	else {
        		B[cnt2]=C[i];
        		cnt2++;
        	}
        }
        if(e>o) {
        	if(e==o+1) {
        		System.out.print(0);
        		return;
        	}
        	else {
        		Arrays.sort(A);
        		int c = e-o-1;
        		int x = 1;
        		while(c>0) {
        			ans += A[e-x];
        			c--;
        			x++;
        		}
        	}
        }
        if(o>e) {
        	if(o==e+1) {
        		System.out.print(0);
        		return;
        	}
        	else {
        		Arrays.sort(B);
        		int c = o-e-1;
        		int x = 1;
        		while(c>0) {
        			ans += B[e-x];
        			c--;
        			x++;
        		}
        	}
        }
        if(o==e) {
        	System.out.print(0);
        	return;
        }
        System.out.print(ans);
		
	}

}
