object Main extends App{
  val sc = new java.util.Scanner(System.in)
  var a , b =sc.nextInt()
  if(b == 0) {print(a);sys.exit()}
  var c = List.fill(b)(sc.nextInt())
  if(c.indexOf(a) == -1){print(a);sys.exit()}
  c :+ a
  c = c.sorted
  var min = 0
  var max = 0
  if (c.indexOf(a) == 0){print(a-1);sys.exit()}
  min = c(c.indexOf(a) - 1)
  if(c.indexOf(a) != b-1) {
    max = c(c.indexOf(a)+1)
  }else{
    max = 105
  }
  var i = a-1
  var j = a+1
  var ans = 0
  while (i == min){
    i-=1
    if(!(c.indexOf(min)-1 == -1)) {
      min = c(c.indexOf(min) - 1)
    }else{
      min = i+1
    }
  }
  while (j == max){
    j+=1
    if(!(c.indexOf(max)+1 > b-1)) {
      max = c(c.indexOf(max) + 1)
    }else{
      max = j+1
    }
  }
  var ia = a-i
  var ja = a-j
  if(ia > a){print(0);sys.exit()}
  if(math.abs(ia)>math.abs(ja)){
    print(j)
  }else{
    print(i)
  }
}
