import java.util.Scanner

import scala.annotation.tailrec

object Main extends App {
  val sc = new Scanner(System.in)
  val X, N = sc.nextInt
  if (N == 0) {
    println(X)
  } else {
    val seq = (0 until N).foldLeft(Vector.fill(100)(true)) { (acc, _) =>
      val next = sc.nextInt - 1
      acc.updated(next, false)
    }

    //    System.err.println(seq)
    @tailrec def loop(n: Int): Int = {
      val small = if (X - n >= 0 && seq(X - n)) {
        Some(X - n)
      } else None
      val large = if (X - 1 + n < 100 && seq(X - 1 + n)) {
        Some(X - 1 + n)
      } else None
      val ans = small.orElse(large)
      if (ans.isEmpty) {
        loop(n + 1)
      } else ans.get
    }

    val ans = loop(0)
    println(ans + 1)
  }
}
