import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class CF1144B {
    public static void main(String[] args) {
      FastReader input = new FastReader();
      int n = input.nextInt();
      long sum = 0;
      ArrayList<Integer> even = new ArrayList<Integer>();
      ArrayList<Integer> odd = new ArrayList<Integer>();
      for(int i = 0;i < n;i++){
          int num = input.nextInt();
          if((num % 2) == 0){
              even.add(num);
          }
          else
              odd.add(num);
          sum += num;
      }
        Collections.sort(even);
        Collections.sort(odd);
        Collections.reverse(even);
        Collections.reverse(odd);
        int minSize = Math.min(even.size(),odd.size());
        for(int i = 0;i < minSize;i++){
            sum -= even.remove(0);
            sum -= odd.remove(0);
        }
        if(even.size() > 0){
            sum -= even.get(0);
        }
        else if(odd.size() > 0){
            sum -= odd.get(0);
        }
        System.out.println(sum);
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            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;
        }
    }
}
