import Foundation
//最大公約数を求める関数
func gcd(_ a: Int, _ b: Int) -> Int {
   let r = a % b
   if r != 0 {
       return gcd(b, r)
   } else {
       return b
   }
}

let rl = readLine()!.split(separator: " ").map({Int($0)!})
let N = rl[0]
let X = rl[1]
let xi = readLine()!.split(separator: " ").map({Int($0)!})

let absxi = xi.map({abs($0 - X)})

print(absxi.min()!)