'use strict';

const inputs = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
const foo = (str) => str.split(' ').map(v => parseInt(v, 10));

const numbers1 = foo(inputs[0]);

if (numbers1[1] === 0) {
  console.log(numbers1[0]);
  return;
}

const target = numbers1[0];

const numbers2 = foo(inputs[1]);

if (!numbers2.includes(target)) {
  console.log(target);
  return;
}

let count1 = target;
let count2 = target;

while(true) {
  --count1;

  if (!numbers2.includes(count1)) {
    console.log(count1);
    return;
  }

  ++count2;

  if (!numbers2.includes(count2)) {
    console.log(count2);
    return;
  }
}