

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

/**
 *
 * @author Haya
 */
public class ParityAlternatedDeletions {

    public static void main(String[] args) {
        
        FastReader in = new FastReader();
        
        int nums = in.nextInt();
 
        ArrayList<Integer> odd = new ArrayList();
        ArrayList<Integer> even = new ArrayList();
 
        for (int i = 0; i < nums; i++) {
            int val = in.nextInt();
            if (val % 2 == 0) 
                even.add(val);
            else 
                odd.add(val);
            
        }
 
        ArrayList<Integer> largest = odd.size() > even.size() ? odd : even;
        Collections.sort(largest);
 
        int total = 0;
        
        int min = Math.min(odd.size(),even.size());
        
        for (int i = min+1; i < odd.size(); i++) {
            total+=odd.get(i);
        }
        
        for (int i = min+1; i <even.size(); i++) {
            total+=even.get(i);
        }
        
        System.out.println(total);


 
    }

    public 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 string = "";
            try {
                string = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return string;
        }

    }

}
