import java.util.Scanner;
import java.util.Arrays;
import java.lang.Math.*;

public class Task {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        String end = in.nextLine();
        
        int b;
        int s1 = 0;
        int s2 = 0;
        
        for (int i=0; i<a; i++) {
            b = in.nextInt();
            if (b % 2 == 1) {
                s1++;
            } else {
                s2++;
            }
        }
        System.out.println(Math.max(0, Math.abs(s1 - s2) - 1));
        System.exit(0);
    }
    
    static class Helper {
        public String sort(String str) {
            char[] arr = str.toCharArray();
            Arrays.sort(arr);
            String res = new String(arr);
            return res;
        }
        
        public boolean isGood(String str) {
            boolean res = true;
            for (int i=1; i<str.length(); i++) {
                //System.out.println(str.charAt(i-1) + " " + str.charAt(i));
                if (str.charAt(i) != str.charAt(i-1) + 1) {
                    res = false;
                    break;
                }
            }
            return res;
        }
    }
}