import java.util.*;

public class changlin_hw1 {
    
    public static void main(String[] args) {
        
        //  https://codeforces.com/problemset/problem/1144/B
        {
            
            Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();
            
            int[] elements = new int[n];
            for (int i = 0; i < elements.length; i++) {
                elements[i] = scanner.nextInt();
            }
            
            System.out.println(minElements(elements));
            
        }
        
        
        //  https://codeforces.com/problemset/problem/1005/B
        {
            
            
            
        }

    }
    
    public static int minElements(int[] elements) {
        
        int oddNums = 0;
        int evenNums = 0;
        
        for (int i = 0; i < elements.length; i++) {
            if (elements[i] % 2 == 0) {
                evenNums++;
            } else {
                oddNums++;
            }
        }
        
        int[] odd = new int[oddNums];
        int[] even = new int[evenNums];
        
        
        int countOdd = 0;
        int countEven = 0;
        
        for (int j = 0; j < elements.length; j++) {
            if (elements[j] % 2 == 0) {
                even[countEven] = elements[j];
                countEven++;
            } else {
                odd[countOdd] = elements[j];
                countOdd++;
            }
        }
        
        Arrays.sort(even);
        Arrays.sort(odd);
        
        int min = 0;
        
        if (even.length == odd.length) {
            return 0;
        } else if (even.length - odd.length == 1 || odd.length - even.length == 1) {
            return 0;
        } else if (even.length > odd.length) {
            for (int k = 0; k <= ((even.length - 1) - (odd.length + 1)); k++) {
                min += even[k];
                return min;
            }
            
        } else if (odd.length > odd.length) {
            for (int l = 0; l <= ((odd.length - 1) - (even.length + 1)); l++) {
                min += odd[l];
                return min;
            }
        }
        
        return -1;
    }
    
    
    
    
    
    
    
    
}