

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader sc = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, sc, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader sc, PrintWriter out) {
            int n=sc.nextInt();
            int[] f=new int[n];
            int[] s=new int[n];
            int index1=0;
            int index2=0;
            long sum=0;
            
            for(int i=0;i<n;i++) {
            	int w=sc.nextInt();
            	sum+=w;
            	if(w%2==0) {
            		s[index2++]=w;
            	}
            	else {
            		f[index1++]=w;
            	}
            }
            Arrays.sort(f,0,index1);
            Arrays.sort(s,0,index2);
            long temp1=0;
        	long temp2=0;
        	
        	for(int i=index2-1,j=index1-1;i>=0&&j>=0;) {
        		temp1+=f[j--];
        		temp1+=s[i--];
        	}
            if(index1-index2-1>=0)
            	temp1+=f[index1-index2-1];
            for(int i=index2-1,j=index1-1;i>=0&&j>=0;) {
            	temp2+=s[i--];
        		temp2+=f[j--];
        	}
            if(index2-index1-1>=0)
            	temp2+=s[index2-index1-1];
            long ans=Math.min(sum-temp1, sum-temp2);
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}
