// Working program with FastReader 
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.*; 

public class Main { 
	static class FastReader { 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() { 
			br = new BufferedReader(new InputStreamReader(System.in)); 
		} 

		String next() { 
			while (st == null || !st.hasMoreElements()){ 
				try{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e){ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() { 
			return Integer.parseInt(next()); 
		} 

		long nextLong() { 
			return Long.parseLong(next()); 
		} 

		double nextDouble() { 
			return Double.parseDouble(next()); 
		} 

		String nextLine()  { 
			String str = ""; 
			try{ 
				str = br.readLine(); 
			} catch (IOException e) { 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	} 

	public static void main(String[] args) { 
		FastReader s=new FastReader(); 
		int n = s.nextInt(); 
		ArrayList<Integer> odd = new ArrayList<>();
		ArrayList<Integer> even = new ArrayList<>();
		for(int i = 0; i<n; i++){
			int x = s.nextInt();
			if (x%2 == 0) even.add(x);
			else odd.add(x);
		} 
		int k = Integer.min(odd.size(), even.size());
		if(even.size() - odd.size() == 1 || odd.size() - even.size() == 1 || even.size() == odd.size()){
			System.out.println(0);
			return;
		}
		Collections.sort(odd,  Collections.reverseOrder());
		Collections.sort(even, Collections.reverseOrder());
/*		for(int i: even)
			System.out.println(i);
		for(int i: odd)
			System.out.println(i);*/

		long sum = 0;
		if(even.size() > odd.size()){
			for(int i = k+1; i<even.size(); i++){
				sum += even.get(i);
			}
		}else{
			for(int i = k+1; i<odd.size(); i++){
				sum += odd.get(i);
			}
		}
		System.out.println(sum);
	} 
} 