import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    PP solver = new PP();
    solver.run(1, in, out);
    out.close();
  }

  static class PP {
    public void run(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      ArrayList<Integer>[] a = new ArrayList[2];
      for (int i = 0; i < 2; i++) {
        a[i] = new ArrayList<>();
      }
      for (int i = 0; i < n; i++) {
        int x = in.nextInt();
        a[x & 1].add(x);
      }
      for (int i = 0; i < 2; i++) {
        Collections.sort(a[i]);
      }
      int ans = 0;
      if (a[0].size() < a[1].size() - 1) {
        for (int i = 0; i < a[1].size() - a[0].size() - 1; i++) {
          ans += a[1].get(i);
        }
      } else if (a[0].size() > a[1].size() + 1) {
        for (int i = 0; i < a[0].size() - a[1].size() - 1; i++) {
          ans += a[0].get(i);
        }
      }
      out.println(ans);
    }
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

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

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