  import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		FastReader sc=new FastReader();
		int n=sc.nextInt();
		/*TreeSet<Integer> a= new TreeSet<>();
		TreeSet<Integer> b= new TreeSet<>();*/
		ArrayList<Integer> a= new ArrayList<>();
		ArrayList<Integer> b= new ArrayList<>();
		for(int i=0;i<n;i++)
		{int c= sc.nextInt();
		if(c%2==0)
		a.add(c);
		else
		b.add(c);
		}
		Collections.sort(a);
		Collections.sort(b);
	//	System.out.println(a.size()+" "+b.size());
		if(a.size()==b.size() || a.size()-b.size()==1 || b.size()-a.size()==1)
		System.out.println("0");
		else
		{
		    int d=0;
		    int sum=0;
		    if(a.size()>b.size())
		    {
		        d= a.size()-b.size()-1;
		        Iterator<Integer> it = a.iterator();
                Integer current = 0;
            while(it.hasNext() && d>0) {
              current = it.next();
              sum= sum+current;
              d--;}

		    }
		    else
		    {
		        d= b.size()-a.size()-1;
		        Iterator<Integer> it = b.iterator();
                Integer current = 0;
            while(it.hasNext() && d>0) {
              current = it.next();
              sum= sum+current;
              d--;}

		    }
		    System.out.println(sum);
		}
	 }
	 
	 
	  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; 
        } 
    } 
    static int gcd(int a,int b)
		{
		    if(a%b==0)
		    return b;
		    return gcd(b,a%b);
		}
		
	static ArrayList<Integer> sieve(int n) 
    { 
        ArrayList<Integer> arr=new ArrayList<Integer>();
        boolean prime[] = new boolean[n+1]; 
        for(int i=0;i<n;i++) 
            prime[i] = true; 
          
        for(int p = 2; p*p <=n; p++) 
        { 
            if(prime[p] == true) 
            { 
                for(int i = p*p; i <= n; i += p) 
                    prime[i] = false; 
            } 
        } 
          
        for(int i = 2; i <= n; i++) 
        { 
            if(prime[i] == true) 
                arr.add(i); 
        } 
        return arr;
    } 
      
	static float power(float x, int y) 
    { 
        float temp; 
        if( y == 0) 
            return 1; 
        temp = power(x, y/2);  
          
        if (y%2 == 0) 
            return temp*temp; 
        else
        { 
            if(y > 0) 
                return x * temp * temp; 
            else
                return (temp * temp) / x; 
        } 
    } 
    static long pow(int a,int b)
    {
        long result=1;
        if(b==0)
        return 1;
        long x=a;
        while(b>0)
        {
            if(b%2!=0)
            result*=x;
            
            x=x*x;
            b=b/2;
        }
        return result;
    }
}