object Main extends App {
  val in = new java.util.Scanner(System.in)
  val X, N = in.nextInt
  val Ps = Array.fill(101)(true)
  (1 to N).foreach {_ => Ps(in.nextInt) = false}

  def search(diff: Int): Int = {
    if (Ps(X - diff)) X - diff
    else if (Ps(X + diff)) X + diff
    else search(diff + 1)
  }

  println(search(0))
}