import java.util.*

fun main(args: Array<String>) {
    val xx = Stack<Int>()

    Scanner(System.`in`).use {
        val n = it.nextInt()
        val x = it.nextInt()
        for (i in 0 until n) {
            xx.push(Math.abs(it.nextInt() - x))
        }
    }

    while (1 < xx.size) {
        val xxx = (0 until 2).map {
            xx.pop()
        }

        val i = if (xxx[1] < xxx[0]) {
            1
        } else {
            0
        }
        xx.push(xxx[i])
        val r = xxx[(i + 1) % 2] % xxx[i]

        if (0 < r) {
            xx.push(r)
        }
    }

    println(xx.pop())
}
