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.*;
import java.math.*;
public class div31
{
    static class InputReader {
        private InputStream stream;
        private byte[] inbuf = new byte[1024];
        private int start= 0;
        private int end = 0;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int readByte() {
            if (start == -1) throw new UnknownError();
            if (end >= start) {
                end= 0;
                try {
                    start= stream.read(inbuf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (start<= 0) return -1;
            }
            return inbuf[end++];
        }

        private boolean isSpaceChar(int c) {
            return !(c >= 33 && c <= 126);
        }

        private int skip() {
            int b;
            while ((b = readByte()) != -1 && isSpaceChar(b)) ;
            return b;
        }

        public String next() {
            int b = skip();
            StringBuilder sb = new StringBuilder();
            while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public long nextLong() {
            long num = 0;
            int b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }
    }
    static long gcd(long a,long b)
    {
        if(b==0)
            return a;
        else 
            return gcd(b,a%b);
    }
    static int count(int x)
    {
        int c=0;
        while(x!=0)
        {
            x&=(x-1);
            c++;
        }
        return c;
    }
    public static void main(String args[])
    {
        InputReader sc=new InputReader(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        List<Integer> l=new ArrayList<>();
        List<Integer> l1=new ArrayList<>();
        for(int i=0;i<n;i++)
        {
            a[i]=sc.nextInt();
            if((a[i]&1)==1)
            l.add(a[i]);
            else
            l1.add(a[i]);
        }
        if((l.size()==l1.size()) || (Math.abs(l1.size()-l.size())==1))
        System.out.println(0);
        else
        {
            Collections.sort(l,(o1,o2)->(o1>o2)?-1:(o1<o2)?1:0);
            Collections.sort(l1,(o1,o2)->(o1>o2)?-1:(o1<o2)?1:0);
            int len=l.size();
            int len1=l1.size();
            int sum=0;
            if(len>len1)
            {
                sum=0;
                for(int i=len-1;i>len1;i--)
                sum+=l.get(i);
            }
            else
            {
                for(int i=len1-1;i>len;i--)
                sum+=l1.get(i);
            }
            System.out.println(sum);
        }
    }
}
