function Main(input) {
  const setting = input.trim().split('\n')
  const x = setting[0].split(' ')[0] - 0
  const arr_length = setting[0].split(' ')[1] - 0

  let ans = 0

  if (arr_length > 0) {
    const num_arr = setting[1].split(' ')
    for (let i = 0; i <= x; i++) {
      let min = x - i
      let answer = num_arr.filter((key) => {
        return parseInt(key) === min
      })
      if (answer.length) {
        let max = x + i
        let answer =num_arr.filter((key) => {
          return parseInt(key) === max
        })
        if (answer.length === 0) {
          console.log(max)
          break
        }
      } else {
        console.log(min)
        break
      }
    }
  } else {
    console.log(x)
  }


  }

Main(require("fs").readFileSync("/dev/stdin", "utf8"));