//import com.sun.source.tree.Tree;
import java.util.*;
import java.io.*;

public class Ahmed {
    public static void main(String[] YAHIA_MOSTAFA) throws IOException, InterruptedException {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        Integer[] x=new Integer[n];int o=0,e=0;long ev=0,odd=0;
        for (int i=0;i<n;++i){
            x[i]=sc.nextInt();
            if (x[i]%2==0) {
                ++e;
               ev+=x[i];
            }
            else {
                ++o;odd+=x[i];
            }
        }
        int c=0;
        Arrays.sort(x);
      //  System.out.println(ev+" "+odd);
        if (Math.abs(o-e)<=1)
            System.out.println(0);
        else if (e>o) {
            c = e - 1 - o;
            for (int i=0;i<n&&c>0;++o){
                if (x[i]%2==0){
                    ev-=x[i];--c;
                }
            }
            System.out.println(ev);
        }
        else {
            c = o - 1 - e;
            for (int i=0;i<n&&c>0;++o){
                if (x[i]%2==1){
                    odd-=x[i];--c;
                }
            }
            System.out.println(odd);
        }
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public Scanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }
    }
}