const main = (input) => {

  let [a, b] = input.trim().split('\n')
  b = b || ''
  
  const [X, N] = a.split(' ').map(v => Number(v))
  const nums = b.split(' ').map(v => Number(v))

  if (N === 0) {
    console.log(X)
    return null
  }

  let smaller = X
  let bigger = X

  while (true) {
    if (nums.indexOf(smaller) === -1) {
      console.log(smaller)
      return null
    } else {
      smaller--
    }

    if (nums.indexOf(bigger) === -1) {
      console.log(bigger)
      return null
    } else {
      bigger++
    }
  }
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))