function main(input) {
  var args = input.split('\n');
  var target = args[0].split(' ')[0];
  var i = target;
  var j = target;
  var forbiddenList = args[1].split(' ');
  while (forbiddenList.indexOf(i + '') >= 0) {
    i--;
  }
  while (forbiddenList.indexOf(j + '') >= 0) {
    j++;
  }
  if (Math.abs(target - i) > Math.abs(target - j)) {
    console.log(j);
  } else {
    console.log(i);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));