import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val X, N = sc.nextInt
  val p = Set.fill(N)(sc.nextInt)

  var i = 0
  var x = Int.MaxValue
  var z = 0
  do {
    if (!p.contains(X - i) && i < x) {
      x = i
      z = X - i
    } else if (!p.contains(X + i) && i < x) {
      x = i
      z = X + i
    }
    i += 1
  } while (x == Int.MaxValue)
  println(z)
}
