const [xn, pStr] = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/)
const [x, n] = xn.split(/\s/).map(Number)
const ps = pStr.split(/\s/).map(Number)

const arr = []

for (const p of ps) {
  if (p === x) {
    arr[0] = 3
    continue
  }
  const d = p - x
  const abs = Math.abs(d)
  arr[abs] = (arr[abs] || 0) + (d > 0 ? 1 : 2)
}
for (let i = 0;; i++) {
  const v = arr[i]
  if (v === 3) {
    continue
  }
  if (v === 2) {
    console.log(x + i)
  } else {
    console.log(x - i)
  }
  break;
}