package ABC109_C_Skip
//import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer

object Skip {
  def main (args: Array[String]) {
    val Array(_, pointX) = io.StdIn.readLine().split(' ').map(_.toInt)
    val cities = io.StdIn.readLine().split(' ').map(_.toInt)
    val distance = new Distance
    println(distance.getD(cities, pointX))
  }
}

class Distance {
  def getD(citiesPoint : Seq[Int], startPoint : Int): Int = {
    val distance : Seq[Int] = getPointCitiesDistance(citiesPoint, startPoint)
    calcGreatestCommonFactor(distance)
  }

  /*
   * 都市と座標Xとの距離(絶対値を求める) 距離0(座標X=都市)は含めない
   */
  private def getPointCitiesDistance(citiesPoint: Seq[Int], startPoint: Int): Seq[Int] = {
    val distanceBuffer = new ArrayBuffer[Int]

    for (point <- citiesPoint) {
      if (point != startPoint) distanceBuffer += (point - startPoint).abs
    }
    val distance = distanceBuffer.toList

    distance
  }

  /*
   * Seq内の値の最大公約数を求める
   */
  //@tailrec
  private def calcGreatestCommonFactor(distance : Seq[Int]) : Int = distance.size match {
        case 2 => calcGCF(distance.head, distance.tail.head)
        case 1 => distance.head
        case _ => calcGCF(calcGreatestCommonFactor(distance.tail), distance.head)
  }

  /*
   * 2数の最大公約数を求める
   */
  //@tailrec
  private def calcGCF(a : Int, b : Int): Int = b match{
    case 0 => a
    case _ if b < a => calcGCF(b, b % a)
    case _ => calcGCF(a, a % b)
  }
}