
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class B1144 {
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int a =sc.nextInt();
        int[] array=new int[a];
        int e=0;
        int o=0;
        for (int i=0;i<array.length;i++)
        {
            array[i]=sc.nextInt();
            if (array[i]%2==0)
            {
                e++;
            }else {
                o++;
            }
        }
        //
        int[] even =new int[e];
        int[] odd=new int[o];
        for (int i=0,k=0,l=0;i<array.length;i++)
        {
            if (array[i]%2==0)
            {
                even[k]=array[i];
                k++;
            }else {
                odd[l]=array[i];
                l++;
            }

        }
        //
        Arrays.sort(even);
        Arrays.sort(odd);
        if (even.length==odd.length+1 || odd.length==even.length+1)
        {
            System.out.println("0");
        }else {
            int sum = 0;
            if (even.length > odd.length) {
               int k = even.length-odd.length;
                for (int i = 0; i < k; i++) {
                    sum = sum + even[i];
                }
            } else {
                int k = odd.length-even.length;
                for (int i = 0; i < k; i++) {
                    sum = sum + odd[i];
                }
            }

            System.out.println(sum);
        }
    }
}
