Polycarp has an array a consisting of n integers.

He wants to play a game with this array. The game consists of several moves. On the first move he chooses any element and deletes it (after the first move the array contains n-1 elements). For each of the next moves he chooses any element with the only restriction: its parity should differ from the parity of the element deleted on the previous move. In other words, he alternates parities (even-odd-even-odd-... or odd-even-odd-even-...) of the removed elements. Polycarp stops if he can't make a move.

Formally: 

  * If it is the first move, he chooses any element and deletes it; 
  * If it is the second or any next move: 
    * if the last deleted element was odd, Polycarp chooses any even element and deletes it; 
    * if the last deleted element was even, Polycarp chooses any odd element and deletes it. 
  * If after some move Polycarp cannot make a move, the game ends. 



Polycarp's goal is to minimize the sum of non-deleted elements of the array after end of the game. If Polycarp can delete the whole array, then the sum of non-deleted elements is zero.

Help Polycarp find this value.

Input

The first line of the input contains one integer n (1 ≤ n ≤ 2000) — the number of elements of a.

The second line of the input contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^6), where a_i is the i-th element of a.

Output

Print one integer — the minimum possible sum of non-deleted elements of the array after end of the game.

Examples

Input


5
1 5 7 8 2


Output


0


Input


6
5 1 2 4 6 3


Output


0


Input


2
1000000 1000000


Output


1000000
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class a{ 
     static int[] count,count1;
     static int[] arr;
     static char[] ch,ch1;
     static long[] darr;
     static Character[][] mat,mat1;
     static int x,h;
     static long maxl;
     static double dec;
     static String s;
     static long minl;
     static int mx = (int)1e6;
     static long mod = 998244353l;
     // static int minl = -1;
     // static long n;
     static int n,n1,n2;
     static long a,g;
     static long b;
     static long c;
     static long d;
     static int y,z;
     static int m;
     static long k;
     static int q;
     static String[] str,str1;
     static Set<Long> set,set1;
     static List<Integer> list,list1;
     static Map<String,Integer> map;
     static StringBuilder sb,sb1,sb2;

     public static void solve(){

        list = new ArrayList<>();
        list1 = new ArrayList<>();

        for(int i = 0 ; i < n ; i++){
            if(arr[i]%2 == 0)
                list.add(arr[i]);
            else
                list1.add(arr[i]);
        }
        int even = list.size();
        int odd = list1.size();

        if(Math.abs(even - odd) <= 1){
            System.out.println("0");
            return;
        }

        long sum = 0;
        if(even > odd){
            Collections.sort(list);
            for(int i = 0 ; i < even-odd-1 ; i++)
                sum += list.get(i);
        }
        else{
            Collections.sort(list1);
            for(int i = 0 ; i < odd-even-1 ; i++)
                sum += list1.get(i);
        }

        System.out.println(sum);

     }

     public static void main(String[] args) {

            FastScanner sc = new FastScanner();
            // Scanner sc = new Scanner(System.in);
            // int t = sc.nextInt();
            int t = 1;
            while(t > 0){
                
                // x = sc.nextLong();
                // y = sc.nextLong();
                // z = sc.nextLong();
                
                // a = sc.nextLong();
                // b = sc.nextLong();
                // c = sc.nextLong();
                // d = sc.nextLong();
                // n = sc.nextLong();
                n = sc.nextInt();
                // y = sc.nextInt();
                // x = sc.nextInt();

                // y = sc.nextLong();
                // n1 = sc.nextInt();
                // n = sc.nextLong();

                // k = sc.nextLong();

                // ch = sc.next().toCharArray();
                // ch1 = sc.next().toCharArray();

                // m = sc.nextInt();
                // k = sc.nextLong();

                arr = new int[n];
                for(int i = 0; i < n ; i++){
                    arr[i] = sc.nextInt();
                }
                
                 
                // darr = new long[m];
                // for(int i = 0; i < m ; i++){
                //     darr[i] = sc.nextLong();
                // }
                
                // n1 = sc.nextInt();
                //  darr = new long[n1];
                //  for(int i = 0; i < n1 ; i++){
                //      darr[i] = sc.nextLong();
                //  }

                // mat = new Character[n][n];
                // for(int i = 0 ; i < n ; i++){
                //     String s = sc.next();
                //     for(int j = 0 ; j < n ; j++){
                //         mat[i][j] = s.charAt(j);
                //     }
                // }
                // str = new String[n];
                // for(int i = 0 ; i < n ; i++)
                //     str[i] = sc.next();

                // System.out.println(solve()?"YES":"NO");
                 solve();       
                 // System.out.println(solve());

                 t -= 1;
            }

     }

    public static int log(long n){

         if(n == 0 || n == 1)
             return 0;

         if(n == 2)
             return 1;

         double num = Math.log(n);
         double den = Math.log(2);

         if(den == 0)
             return 0;

         return (int)(num/den);
     }

     public static long gcd(long a,long b){

        if(b%a == 0)
            return a;

        return gcd(b%a,a);

     }

     // public static void swap(int i,int j){
     //     long temp = arr[j];
     //     arr[j] = arr[i];
     //     arr[i] = temp;
     // } 

    static final Random random=new Random();
    
    static void ruffleSort(long[] a) {
        int n=a.length;//shuffle, then sort 
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n);
            long temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }

    static class Node{
        int first;
        int second;
        Node(int f,int s){
            this.first = f;
            this.second = s;
        }
    }

     static class FastScanner {

                BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st=new StringTokenizer("");
                String next() {
                        while (!st.hasMoreTokens())
                                try {
                                        st=new StringTokenizer(br.readLine());
                                } catch (IOException e) {
                                        e.printStackTrace();
                                }
                        return st.nextToken();
                }
                
                int nextInt() {
                        return Integer.parseInt(next());
                }
                int[] readArray(int n) {
                        int[] a=new int[n];
                        for (int i=0; i<n; i++) a[i]=nextInt();
                        return a;
                }
                long nextLong() {
                        return Long.parseLong(next());
                }
        }

}