
import java.util.Arrays;
import java.util.Scanner;

public class Parity {
		public static void main(String[] args) {
			Scanner line = new Scanner(System.in);
			int n = line.nextInt();
			int pair =0, impair=0;
			int T1[] =new int[n];
			int T2[] =new int[n];
			long sum=0;
			for(int i=0; i<n;i++) {
				int m = line.nextInt();
				if(m%2==0) {
					T1[pair] =m;
					pair++;
				}
				else {
					T1[impair] =m;
					impair++;
				}
			}
			if(n == 2) {
				if(pair==impair)  System.out.println(0);
				else {
					if(pair==2) {
						System.out.println(Math.min(T1[0], T1[1]));
					}
					else if(impair==2) {
						System.out.println(Math.min(T2[0], T2[1]));
					}
						
				}
			}
			else if(pair==impair) System.out.println(0);
			else if(Math.abs(pair-impair)==1) {
				System.out.println(0);
			}
			else {
				int max =Math.max(pair, impair);
				int min =Math.min(pair, impair);
				int h = max-min-1;
				if(max==pair) {
					Arrays.sort(T1);
					for(int j=0; j<h;j++) {
						sum+=T1[j];
					}
				}
				else {
					Arrays.sort(T2);
					for(int j=0; j<h;j++) {
						sum+=T2[j];
					}
				}
				System.out.println(sum);
			
			}

}}
