import java.util.Arrays;
import java.util.Scanner;

public class probB {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);

        int size=scanner.nextInt();


        int arr[]=new int[size];
        int odd=0;
        int even=0;
        for(int i=0;i<size;i++){
                arr[i]=scanner.nextInt();

                if(arr[i]%2==0)even++;
                else odd++;
        }

        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));
        int ans=0;
        if(odd>even){
            int left=odd-even-1;
            for(int i=0;i<left;i++){
                if(arr[i]%2!=0)
                ans+=arr[i];
            }
        }else if(even>odd){
            int left=even-odd-1;
            for(int i=0;i<left;i++){
                if(arr[i]%2==0)
                    ans+=arr[i];
            }

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