import scala.util.control.Breaks

object Main extends App {
  val xn =  scala.io.StdIn.readLine()
  val xnArray = xn.split(" ").map(_.toInt).toSeq
  val x = xnArray(0)
  val n = xnArray(1)

  val pInput =  scala.io.StdIn.readLine()

  if (n == 0) {
    println(x)
  } else {
    val pArray = pInput.split(" ").map(_.toInt).toVector.sorted
    if (pArray.find(_ == x).isEmpty) {
      println(x)
    } else {
      val b = new Breaks
      var result = -999
      var sabun = -999
      b.breakable {
        val min = pArray.head - 1
        val minSabun = Math.abs(x - min)

        var temp = -999
        sabun = minSabun
        result = min
        pArray.zipWithIndex.foreach { p =>
          if (temp == -999) {
            temp = p._1
          } else if (temp + 1 == p._1) {
            temp = p._1
          } else {
            // 現状より一つ前の値
            val next = p._1 - 1
            (temp + 1 to next).foreach { i =>
              val tempSabun = Math.abs(x - i)
              if (tempSabun < minSabun) {
                sabun = tempSabun
                result = i
              }
            }
            temp = p._1
          }
        }
      }
      println(result)
    }
  }
}