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

public class ParityAlteredDeletions {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = scanner.nextInt();
        int[] arr = new int[N];
        int[] arrParity = new int[2];
        int[] copyParity = new int[2];
        long sum = 0;
        for(int i= 0; i < N; i++) {
            arr[i] = scanner.nextInt();
            sum += arr[i];
            arrParity[arr[i]%2]++;
            copyParity[arr[i]%2]++;
        }
        //start with an odd
        long arrSum = sum;
        int cur = 0;
        boolean[] rem = new boolean[N];
        while(true) {
            if (arrParity[cur] == 0) break;
            int ind = -1;
            int bestVal = 0;
            for(int i = 0; i < N; i++) {
                if (!rem[i] && arr[i] > bestVal) {
                    bestVal = arr[i];
                    ind = i;
                }
            }
            rem[ind] = true;
            arrSum -= arr[ind];
            arrParity[cur]--;
            cur = 1-cur;
        }
        rem = new boolean[N];
        cur = 1;
        while(true) {
            if (copyParity[cur] == 0) break;
            int ind = -1;
            int bestVal = 0;
            for(int i = 0; i < N; i++) {
                if (!rem[i] && arr[i] > bestVal) {
                    bestVal = arr[i];
                    ind = i;
                }
            }
            rem[ind] = true;
            sum -= arr[ind];
            copyParity[cur]--;
            cur = 1-cur;
        }
        out.println(Math.min(sum, arrSum));
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(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 readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}
