
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;

import javax.swing.text.InternationalFormatter;

import java.math.*;

import org.omg.CORBA.Any;

public class template {

	static int n = 0, m = 0, k = 0;

	public static void main(String[] args) throws IOException {
		Scanner scn = new Scanner(System.in);

		   int n=scn.nextInt();
		    ArrayList<Integer> o=new ArrayList<>();
		    ArrayList<Integer> e=new ArrayList<>();
		    
		    for(int i=0; i<n; i++){
		    	int x=scn.nextInt();
		    	
		    	 if(x%2 == 0)
		    		 e.add(x);
		    	 else
		    		 o.add(x);
		    }
		    
            Collections.sort(o, Collections.reverseOrder()); Collections.sort(e, Collections.reverseOrder());
            long ans=0;
            
            
            if(e.size() == 0){
            	long p=0;
            	for(int i=1; i<o.size(); i++)
            		p+=o.get(i);
            	
            	System.out.println(p);
            	
            }
            
            else if(o.size() == 0){
            	long p=0;
            	for(int i=1; i<e.size(); i++)
            		p+=e.get(i);
            	
            	System.out.println(p);
            	
            }
            
            else if(Math.abs(e.size()-o.size())<=1)
		    	System.out.println(0);
		    
		    else{
		    	
		    	    if(o.size() < e.size()){
		    	    	int d=o.size();
		    	    	
		    	    	for(int i=0; i<e.size(); i++){
		    	    		  if(d==-1)
		    	    			  ans+=e.get(i);
		    	    		  else
		    	    			  d--;
		    	    	}
		    	    }
		    	    
		    	    else{
		    	    	 int d=e.size();
		    	    	 for(int i=0; i<o.size(); i++){
		    	    		  if(d==-1)
		    	    			  ans+=o.get(i);
		    	    		  else
		    	    			  d--;
		    	    	}
		    	    }
		    	    
		    	    
		    	    System.out.println(ans);
		    }
		}
	}

	//



// _________________________TEMPLATE_____________________________________________________________

class pair implements Comparable<pair> {
	int rating;
	int div;

	pair(int l, int b) {
		rating = l;
		div = b;
	}

	@Override
	public int compareTo(pair o) {

		return this.rating - o.rating;
	}

	public static void printarray(long[] dp1) {
		for (long i : dp1)
			System.out.print(i + " ");
		System.out.println();
	}

	public static void inputarray(long[] a, int n, Reader scn) throws IOException {
		for (int i = 0; i < n; i++)
			a[i] = scn.nextLong();
	}

	public static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[100000 + 1]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}

	// private static void rem(HashMap<Integer, Integer> hm) {
	//
	// Iterator<Map.Entry<Integer, Integer>> itr = hm.entrySet().iterator();
	// ArrayList<Integer> p=new ArrayList<>();
	//
	//
	// while(itr.hasNext()){
	// Map.Entry<Integer, Integer> entry = itr.next();
	// p.add(entry.getKey());
	//
	// }
	//
	//
	// for(int i:p){
	//
	// if(hm.get(i)>1)
	// hm.put(i, hm.get(i)-1);
	// else
	// hm.remove(i);
	// }
	// }

}
