import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String args[]) {
        // System.out.println("Hello World!");
       Scanner scn = new Scanner(System.in);
       int n = scn.nextInt();
       ArrayList<Integer> odd = new ArrayList<>();
       ArrayList<Integer> even = new ArrayList<>();
       for(int i=0;i<n;++i){
          int temp = scn.nextInt();
          if(temp%2==0){
              even.add(temp);
          }
          else{
              odd.add(temp);
          }
       }
       Collections.sort(odd);
       Collections.sort(even);
       int od = odd.size();
       int ev = even.size();

       int count = 0;
       int ans = 0;
       if(od>ev){
           for(int j=ev+1;j<od;++j){
               ans+= odd.get(j);
           }
           System.out.println(ans);
       }else if(od==ev){
           System.out.println(ans);
       }else{
           for(int j=od+1;j<ev;++j){
               ans+= even.get(j);
           }
           System.out.println(ans);
       }
   }
}