/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static void main (String[] args) 
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] even = new int[2005];
		int[] odd = new int[2005];
		int cte = 0, cto = 0, sum = 0;
		for (int i = 0; i < n; ++i){
			int tmp;
			tmp = in.nextInt();
			if (tmp % 2 == 0){
				even[cte] = tmp;
				++cte;
			}
			else{
				odd[cto] = tmp;
				++cto;
			}
			sum += tmp;
		}
		if (cte == 0){
			System.out.println(sum - odd[cto - 1]);
			System.exit(0);
		}
		else if (cto == 0){
			System.out.println(sum - even[cte - 1]);
			System.exit(0);
		}
		Arrays.sort(even, 0, cte - 1);
		Arrays.sort(odd, 0, cto - 1);
		boolean start = false;
		if (even[cte - 1] < odd[cto - 1]) start = true;
		while (true){
			if (start){
				if (cto == 0) break;
				sum -= odd[cto - 1];
				--cto;
				start = false;
			}
			else {
				if (cte == 0) break;
				sum -= even[cte - 1];
				--cte;
				start = true;
			}
		}
		System.out.println(sum);
	}
}