import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class test2 {

    public static void main(String[] args) throws IOException {
        Scanner s=new Scanner(System.in);
        int n = s.nextInt();
        int[] a=new int[n];
        int sumOdd=0,sumEven=0,countEven=0,countOdd=0;
        for(int i=0;i<n;i++)
        {
            a[i]=s.nextInt();
            if(a[i]%2==0){sumEven=sumEven+a[i];countEven++;}
            else{
               sumOdd=sumOdd+a[i];
               countOdd++;
            }
        }
        Arrays.sort(a);
        if(Math.abs(countEven-countOdd)<=1)
        {
            System.out.println(0);
        }else if(countEven==0)
        {
            System.out.println(sumOdd-a[n-1]);
        }else if(countOdd==0)
        {
            System.out.println(sumEven-a[n-1]);
        }
        else
        {
            if(countEven>countOdd){

                for (int i = n-1; i>=0 ; i--) {
                    if(a[i]%2==0){sumEven=sumEven-a[i];countEven--;break;}
                }

                 for(int i=n-1;i>=0;i--) {

                     if(i%2!=0 && countEven!=0 )
                     {
                         for (int k = i; k>=0 ; k--) {
                             if(a[k]%2==0){sumEven=sumEven-a[k];countEven--;break;}
                         }

                     }else if(i%2==0 && countOdd!=0)
                     {
                         for (int k = i; k>=0 ; k--) {
                             if(a[k]%2!=0){sumOdd=sumOdd-a[k];countOdd--;break;}
                         }
                     }else
                     {
                         break;
                     }

                 }
                System.out.println(sumEven+sumOdd);

            }else
            {
                for (int i = n-1; i>=0 ; i--) {
                    if(a[i]%2!=0){sumOdd=sumOdd-a[i];countOdd--;break;}
                }

                for(int i=n-1;i>=0;i--) {

                    if(i%2!=0 && countEven!=0 )
                    {
                        for (int k = i; k>=0 ; k--) {
                            if(a[k]%2==0){sumEven=sumEven-a[k];countEven--;break;}
                        }

                    }else if(i%2==0 && countOdd!=0)
                    {
                        for (int k = i; k>=0 ; k--) {
                            if(a[k]%2!=0){sumOdd=sumOdd-a[k];countOdd--;break;}
                        }
                    }else
                    {
                        break;
                    }

                }
                System.out.println(sumEven+sumOdd);
            }

        }


    }
}