import java.io.*;
import java.util.*;
 
public class Main{
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      
      //begin
      int n = sc.nextInt();
      ArrayList<Integer> odd = new ArrayList<Integer>();
      ArrayList<Integer> even = new ArrayList<Integer>();
      for(int i = 0; i < n; i++)
      {
          int a = sc.nextInt();
          if(a % 2 == 0)
            even.add(a);
          else
            odd.add(a);
      }
      if(Math.abs(even.size() - odd.size()) <= 1)
        out.println(0);
      else
      {
          Collections.sort(even);
          Collections.sort(odd);
          int sum = 0;
          if(even.size() > odd.size())
            for(int i = 0; i < even.size() - odd.size() - 1; i++)
                sum += even.get(i);
          else
            for(int i = 0; i < even.size() - odd.size() - 1; i++)
                sum += odd.get(i);
          out.println(sum);
      }
      //end
      out.close();
   }
 
   public static PrintWriter out;
      
   public 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;
      }
   }
}