import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class probB {
    public static void main(String[] args) throws IOException{
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();

        List<Integer> odd = new ArrayList<>();
        List<Integer> even = new ArrayList<>();

        boolean firstEven = sc.nextInt() % 2 == 0;
        boolean sortCalled = false;
        for (int i = 0; i < n-1; i++) {
            int num = sc.nextInt();
            if(num %2 == 0) even.add(num);
            else odd.add(num);
        }
        int ans=0;
        if(even.size() == odd.size()) ans = 0;
        else{
            if(firstEven && odd.size() > 0) {
                Collections.sort(odd);
                //sortCalled = true;
                odd.remove(odd.size()-1);
            }
            else if(!firstEven && even.size() > 0) {
                Collections.sort(even);
                //sortCalled = true;
                even.remove(even.size()-1);
            }

            List<Integer> greater = (even.size() > odd.size()? even:odd);
            List<Integer> lesser = (even.size() < odd.size() ? even:odd);
            //if(!sortCalled)
            Collections.sort(greater);
            Integer[] arr = new Integer[greater.size()];
            arr = greater.toArray(arr);

            int dif = greater.size() - lesser.size();
            for (int i = 0; i < dif; i++) {
                ans += arr[i];
            }
        }

        out.println(ans);
        out.flush();
    }
    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        MyScanner(String fileName) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(fileName));
        }

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

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

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

        long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

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