import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int e = 0;
		int o = 0;
		int[] a = new int[n];
		long sumE = 0;
		long sumO = 0;

		for (int i = 0; i < n; i++) {
			int x = in.nextInt();
			a[i] = x;

			if (x % 2 == 0) {
				sumE += x;
				++e;
			} else {
				sumO += x;
				++o;
			}
		}
		if (Math.abs(e - o) > 1) {
			Arrays.sort(a);
			if (e > o) {
				int max = o + 1;
				for (int i = n - 1; i > -1; i--) {
					if (a[i] % 2 == 0 && max > 0) {
						sumE -= a[i];
						--max;
					}
				}
				out.println(sumE);
			} else {
				int max = e + 1;
				for (int i = n - 1; i > -1; i--) {
					if (a[i] % 2 != 0 && max > 0) {
						sumO -= a[i];
						--max;
					}
				}
				out.println(sumO);
			}
			
		} else {
			out.println(0);
		}

		out.flush();
		out.close();

	}

	static class FastReader {
		StringTokenizer st;
		BufferedReader br;

		public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

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

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

		public int[] nextIntArray(int n) throws IOException {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextInt();
			}
			return ret;
		}

		public long[] nextIntLong(int n) throws IOException {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextLong();
			}
			return ret;
		}

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

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

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

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

}