import java.util.*;
import java.lang.*;
public class MyClass {
    public static void main(String args[]) {
        Scanner read = new Scanner(System.in);
        int n = read.nextInt();
        int array[] = new int[n];
        for(int i = 0; i<n; i++){
            array[i] = read.nextInt();
        }
        int even = 0;
        int odd = 0;
        for(int r = 0; r<n; r++){
            if(array[r]%2 == 0){
                even++;
            }
            else{
                odd++;
            }
        }
        int sub = Math.abs(even - odd);
        if(sub == 0 || sub == 1){
            System.out.println(0);
        }
        else if (sub == even || sub == odd){
            System.out.println(sub);
        }
        else{
            System.out.println(sub - 1);
        }
    }
}
