import java.util.*;

public class B {
	static long[] vals;
	static int n;

	public static void main(String[] args) {
		Scanner console = new Scanner(System.in);
		n = console.nextInt();
		vals = new long[n];
		for (int i = 0; i < n; i++) {
			vals[i] = console.nextInt();
		}
		solve();
	}

	public static void solve() {
		Arrays.sort(vals);
		//System.out.println(Arrays.toString(vals));
		boolean[] deleted = new boolean[n];
		boolean[] iseven = new boolean[n];
		for (int i = 0; i < n; i++) {
			if (vals[i] % 2 == 0)
				iseven[i] = true;
		}
		
		//System.out.println(Arrays.toString(iseven));
		
		//start with even
		//1 2 5 7 8
		long resulteven = 0;
		boolean removeeven = true;
		for (int i = n-1; i>=0; i--) 
		{
			//System.out.println("i is "+i);
			if (removeeven) {
				if (iseven[i]&&!deleted[i]) {
					deleted[i] = true;
					removeeven = false;
					resulteven+=vals[i];
					//System.out.println("Added "+vals[i]);					
					i = n;
				}
			}
			else {
				if (!iseven[i]&&!deleted[i]) {
					deleted[i] = true;
					removeeven = true;
					resulteven+=vals[i];
					//System.out.println("Added "+vals[i]);
					i = n;
				}
			}
		}
		
		//System.out.println("By starting with even, deleted "+resulteven+"\n\n");
		
		Arrays.fill(deleted, false);
		//start with odd
		long resultodd = 0;
		removeeven = false;
		for (int i = n-1; i>=0; i--) 
		{
			//System.out.println("i is "+i);
			if (removeeven) {
				if (iseven[i]&&!deleted[i]) {
					deleted[i] = true;
					removeeven = false;
					resultodd+=vals[i];
					//System.out.println("Added "+vals[i]);					
					i = n;
				}
			}
			else {
				if (!iseven[i]&&!deleted[i]) {
					deleted[i] = true;
					removeeven = true;
					resultodd+=vals[i];
					//System.out.println("Added "+vals[i]);
					i = n;
				}
			}
		}
		
		//System.out.println("By starting with odd, deleted "+resultodd);
		
		long sum = getSum();
		long maxRem = Math.max(resultodd, resulteven);
		System.out.println(sum-maxRem);
	}
	
	public static long getSum() {
		long res = 0;
		for (long l : vals) {
			res+=l;
		}
		return res;
	}
}
