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);
        }
    }
}
