
import java.util.*;

public class Parity {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		//int even=0, odd=0;
		int sum=0;
		ArrayList<Integer> odd = new ArrayList<>();
		ArrayList<Integer> even = new ArrayList<>();
		for(int i=0;i<n;i++) {
			int x = sc.nextInt();
			//li.add(x);
			if(x%2==0) {
				even.add(x);
			}else {
				odd.add(x);
			}
			
		}
		Collections.sort(even);
		Collections.sort(odd);
		if(odd.size()==even.size()) {
			System.out.println(0);
		}else if(odd.size()>even.size()) {
			if(odd.size()==even.size()+1) {
				System.out.println(0);
			}else if(even.size()==0) {
				for(int j=1;j<n;j++) {
					sum=sum+odd.get(j);
				}
				System.out.println(sum);
			}
			else {
				int size = odd.size()-even.size();
				for(int j=0;j<size;j++) {
					sum=sum+odd.get(j);
				}
				System.out.println(sum);
			}
		}else {
			if(even.size()==odd.size()+1) {
				System.out.println(0);
			}else if(odd.size()==0) {
				for(int j=1;j<n;j++) {
					sum=sum+even.get(j);
				}
				System.out.println(sum);
			}
			else {
				int size = even.size()-odd.size();
				for(int j=0;j<size;j++) {
					sum=sum+even.get(j);
				}
				System.out.println(sum);
			}
			
		}
	}

}
