object Main {
  def main(args: Array[String]): Unit = {
    val balls_num  = scala.io.StdIn.readInt
    val robotB_x   = scala.io.StdIn.readInt
    val balls_x    = scala.io.StdIn.readLine.split(" ").map{_.toInt}
    var total_move = 0

    balls_x.foreach { i =>
      val robotB_dis = Math.abs( i - robotB_x ).toInt
      if( robotB_dis < i ) total_move += robotB_dis else total_move += i
    }

    println( total_move*2 )
  }
}