"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const X = parseInt(arg[0].split(" ")[1]);
    const numbers = arg[1].split(" ").map(n=>parseInt(n));
    
    const evenOdd = numbers.filter(n=>n % 2 === 0).length;
    
    if(N === 1) {
        console.log(numbers[0] - X);
        return;
    }
    
    if(evenOdd === 0 !== N && evenOdd !== 0) {
        console.log(1);
        return;
    }
    
    let answer = Math.abs(numbers[0] - X);
    
    for(let i=1; i<N; i++) {
        let temp = Math.abs(numbers[i] - X);
        
        if(temp < answer) {
            answer = temp;
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));