import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.IntStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Ruins He
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    OutputWriter out = new OutputWriter(outputStream);
    TaskB solver = new TaskB();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      int n = in.nextInt();
      int[] arr = in.nextInts(n);
      int[] odds = Arrays.stream(arr).filter(number -> number % 2 == 1).toArray();
      int[] evens = Arrays.stream(arr).filter(number -> number % 2 == 0).toArray();
      Arrays.sort(odds);
      Arrays.sort(evens);

      int sum = 0;
      for (int odd : odds) {
        sum += odd;
      }
      for (int even : evens) {
        sum += even;
      }
      int deleted = Math.min(odds.length, evens.length);
      for (int i = 0; i < deleted; i++) {
        sum -= odds[odds.length - 1 - i] + evens[evens.length - 1 - i];
      }
      int first = deleted == odds.length ? 0 : odds[odds.length - 1 - deleted];
      int second = deleted == evens.length ? 0 : evens[evens.length - 1 - deleted];
      sum -= Math.max(first, second);
      out.println(sum);
    }

  }

  static class InputReader {
    public final BufferedReader reader;
    public StringTokenizer tokenizer = null;

    public InputReader(Reader reader) {
      this.reader = new BufferedReader(reader, 32767);
    }

    public InputReader(InputStream inputStream) {
      this(new InputStreamReader(inputStream));
    }

    public String next() {
      if (hasNext()) return tokenizer.nextToken();
      else throw new NoSuchElementException();
    }

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

    public int[] nextInts(int n) {
      int[] res = new int[n];
      for (int i = 0; i < n; i++) res[i] = nextInt();
      return res;
    }

    public boolean hasNext() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          String nextLine = reader.readLine();
          if (nextLine == null) return false;
          tokenizer = new StringTokenizer(nextLine);
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.hasMoreTokens();
    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

    private OutputWriter(Writer writer, boolean autoFlush) {
      this.writer = new PrintWriter(new BufferedWriter(writer, 32767), autoFlush);
    }

    public OutputWriter(Writer writer) {
      this(writer, true);
    }

    public OutputWriter(OutputStream outputStream) {
      this(new OutputStreamWriter(outputStream), false);
    }

    public OutputWriter println(int value) {
      writer.println(value);
      return this;
    }

    public void close() {
      writer.close();
    }

  }
}

