import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

	static InputStreamReader isr;
	static BufferedReader br;
	static OutputStreamWriter osw;
	static BufferedWriter bw;
	static StringTokenizer st;
	
	public static void main(String[] args) throws IOException {

		isr = new InputStreamReader(System.in);
		br = new BufferedReader(isr);
		osw = new OutputStreamWriter(System.out);
		bw = new BufferedWriter(osw);
		
		int N = Integer.parseInt(br.readLine());
		
		ArrayList<Long> oddList = new ArrayList<Long>();
		ArrayList<Long> evenList = new ArrayList<Long>();
		
		st = new StringTokenizer(br.readLine());
		for(int i = 0; i < N; i++) {
			long value = Long.parseLong(st.nextToken());
			
			if(value % 2 == 0) {
				evenList.add(value);
			}else {
				oddList.add(value);
			}
		}
		
		
		Collections.sort(evenList);
		Collections.sort(oddList);
		
		if(evenList.size() == oddList.size()) {
			bw.write("0");
		} else if(Math.abs(evenList.size() - oddList.size()) == 1) {
			bw.write("0");
		} else {
			
			long minValue = 0;
			
			if(evenList.size() == 0) {
				for(int index = 0; index < oddList.size() - 1; index++) {
					minValue += oddList.get(index);
				}
			}
			else if(oddList.size() == 0) {
				for(int index = 0; index < evenList.size() - 1; index++) {
					minValue += evenList.get(index);
				}
			} else {
				if(evenList.size() > oddList.size()) {
					int len = evenList.size() - oddList.size() +	 1;
					
					for(int index = 0; index < len; index++) {
						minValue += evenList.get(index);
					}
				}else {
					int len = oddList.size() - evenList.size() + 1;
					
					for(int index = 0; index < len; index++) {
						minValue += oddList.get(index);
					}
				}
			}
			
			bw.write(minValue + "");
		}
		
		bw.flush();
		bw.close();
		br.close();
	}	
}