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

public class Main {
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1024 * 1024 * 2);

        int n = Integer.valueOf(br.readLine());
        int v[] = readArrayLine(br.readLine(), n);
        Arrays.sort(v);

        int countOdd = 0;
        int countEven = 0;
        for (int i = 0; i < n; i++) {
            if (v[i] % 2 == 1) {
                countOdd++;
            } else {
                countEven++;
            }
        }

        if (Math.abs(countEven - countOdd) <= 1) {
            System.out.println(0);
        } else {
            long sum = 0;
            if (countEven > countOdd) {
                int diff = countEven - countOdd - 1;
                for (int i = 0; i < n; i++) {
                    if (v[i] % 2 == 0) {
                        sum += v[i];
                        diff--;
                    }
                    if (diff == 0) {
                        break;
                    }
                }
            } else {
                int diff = countOdd - countEven - 1;
                for (int i = 0; i < n; i++) {
                    if (v[i] % 2 == 1) {
                        sum += v[i];
                        diff--;
                    }
                    if (diff == 0) {
                        break;
                    }
                }
            }
            System.out.println(sum);
        }
    }

    public static int[] readArrayLine(String line, int n) {
        return readArrayLine(line, n, null, 0);
    }

    private static int[] readArrayLine(String line, int n, int array[], int pos) {
        int[] ret = array == null ? new int[n] : array;
        int start = 0;
        int end = line.indexOf(' ', start);
        for (int i = pos; i < pos + n; i++) {
            if (end > 0)
                ret[i] = Integer.parseInt(line.substring(start, end));
            else
                ret[i] = Integer.parseInt(line.substring(start));
            start = end + 1;
            end = line.indexOf(' ', start);
        }
        return ret;
    }
}
