"use strict";

const main = (arg) => {
  const array = arg.trim().split("\n");
  const array_A = array[0].trim().split(" ");
  const X = parseInt(array_A[0]);
  const N = parseInt(array_A[1]);
  if (N == 0) {
    console.log(X);
    return;
  }
  let array_B = array[1].trim().split(" ");
  array_B.sort(function (a, b) {
    return parseInt(a) < parseInt(b) ? -1 : 1;
  });

  let min = array_B[0];
  let max = array_B[N - 1];
  let maxNumber = 0;
  let minNumber = 0;

  for (let i = X; i < max; i++) {
    let maxFlag = true;
    for (let j = 0; j < array_B.length; j++) {
      // console.log(array_B[j]);
      if (array_B[j] == i) {
        maxFlag = false;
      }
    }
    if (maxFlag) {
      maxNumber = i;
      break;
    }
  }
  if (maxNumber == 0) {
    maxNumber = parseInt(max) + 1;
  }

  for (let k = X; min <= k; k--) {
    let minFlag = true;
    for (let l = 0; l < array_B.length; l++) {
      if (array_B[l] == k) {
        minFlag = false;
      }
    }
    if (minFlag) {
      minNumber = k;
      break;
    }
  }
  if (minNumber == 0) {
    minNumber = parseInt(min) - 1;
  }

  let result = 0;
  let maxResult = maxNumber - X;
  let minResult = X - minNumber;

  if (maxResult == minResult) {
    console.log(minNumber);
  } else if (maxResult < minResult) {
    console.log(maxNumber);
  } else if (minResult < maxResult) {
    console.log(minNumber);
  }
};
main(require("fs").readFileSync("/dev/stdin", "utf8"));
// main("6 5\n4 7 10 6 5");
// main("6 0\n");
// https://atcoder.jp/contests/abc170/tasks/abc170_c
