
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


import java.util.Collections;
import java.util.LinkedList;
import java.util.StringTokenizer;


public class MainClass {

    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 in = new FastReader();
        int n = in.nextInt() ; long sum = 0 ;
        LinkedList<Integer> odd = new LinkedList<>() ;
        LinkedList<Integer> even = new LinkedList<>() ;
        for (int i = 0 ; i < n ; i++)
        {
            int input = in.nextInt() ;
            if (input%2 == 0)
                even.addLast(input);
            else
                odd.addLast(input);
        }
        Collections.sort(odd,Collections.reverseOrder());
        Collections.sort(even,Collections.reverseOrder());
        if (Math.abs(even.size()-odd.size()) <= 1)
        {
            System.out.println(0);
            return;
        }
        else if (even.size() > odd.size())
        {
            for (int i = odd.size()+1 ; i < even.size() ; i++)
                sum+= even.get(i);
        }
        else if (even.size() < odd.size())
        {
            for (int i = even.size()+1 ; i < odd.size() ; i++)
                sum+= odd.get(i);
        }
        System.out.println(sum);

    }
}