var lines=[];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', function (line) {
  lines.push(line);
});
reader.on('close', function () {
    const vals = lines[0].split(' ');
    const X = vals[0],N = vals[1];
    const ps = lines[1].split(' ');

    if(ps.includes(X)){
        var val1 = Number(X)-1;
        var val2 = Number(X)+1;
        while(ps.includes(val1.toString()) && ps.includes(val2.toString())){
                val1--;
                val2++;
        }

        if(ps.includes(val1.toString()))
            console.log(val2);
        else if(ps.includes(val2.toString))
            console.log(val1);
        else{
            const result = Math.abs(val1 - X) <= Math.abs(val2-X) ? val1 : val2;
            console.log(result);
        }
        return;
    }

    console.log(X);
});