//package codforces;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;


public class Main {
	
	LinkedList<Integer> adj[];
	int[] respecc_array;
	
	public static void main(String[] args)throws IOException
	{
		Reader.init(System.in);
		int no = Reader.nextInt();
		PriorityQueue<Integer> pque = new PriorityQueue<Integer>();
		int count_odd = 0;
		int count_even =0 ;
		for( int i=0; i<no; i++)
		{
			int x = Reader.nextInt();
			pque.add(x);
			if(x%2==0)
				count_even++;
			else
				count_odd++;
		}
		if(count_even==count_odd)
		{
			System.out.println(0);
		}
		else if(count_even>count_odd)
		{
			int required = count_even - count_odd-1;
			if(required==0)
			{
				System.out.println(0);
				return;
			}
			long sum = 0;
			while(required>=1)
			{
				int top = pque.poll();
				if(top%2==0)
				{
					sum+=top;
					required--;
				}
			}
			System.out.println(sum);
			
		}
		else
		{
			int required = count_odd - count_even-1;
			if(required==0)
			{
				System.out.println(0);
				return;
			}
			long sum = 0 ;
			while(required>=1)
			{
				int top = pque.poll();
				if(top%2!=0)
				{
					required--;
					sum+=top;
				}
			}
			System.out.println(sum);
			
		}
		
		
		
	}
}
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }
    
    static long nextLong() throws IOException{
    	return Long.parseLong(next());
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}