import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Codeforce1144B {
    public static void main(String[] args)throws Exception{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int odd = 0;
        int even = 0;
        for (int i = 0; i < n; i++) {
            if (Integer.parseInt(tokenizer.nextToken()) % 2 == 0){
                even++;
            }else{
                odd++;
            }
        }

        if (odd == even)
            System.out.println(0);
        else
            System.out.println(Math.abs(odd - even) - 1);
    }
}
