import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class PAD {
    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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;
        }
    }

    private static int helper(int[] arr, int n, MyScanner ms) {
        int evens = 0, odds = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = ms.nextInt();
            if (arr[i] % 2 == 1) odds++;
            else evens++;
        }

        if (evens == odds) {
            return 0;
        }

        Arrays.sort(arr);

        int leftEvens = 0, leftOdds = 0;
        if (evens  > odds) {
            leftEvens = evens - odds - 1;
            leftOdds = 0;
        }
        else {
            leftOdds = odds - evens - 1;
            leftEvens = 0;
        }


        int sum = 0;
        int evenCnt = 0, oddCnt = 0;
        for (int i = 0; i < n; i++) {
            if (arr[i] % 2 == 0 && evenCnt < leftEvens) {
                sum += arr[i];
                evenCnt++;
            }
            if (arr[i] % 2 == 1 && oddCnt < leftOdds) {
                sum += arr[i];
                oddCnt++;
            }
        }


        return sum;

    }
    public static void main(String[] args) {
        MyScanner ms = new MyScanner();
        int n = ms.nextInt();
        int[] arr = new int[n];

        System.out.println(helper(arr, n, ms));

    }
}
