function Main(input) {
	var str = input;
	var flg = false;
	var flg2 = true;
	var c = 1;
	var ab=[];
	var tar = 0;
	var ans = 0;//数字の場合	
	var str = str.split("\n");//一行の場合
	var num = str[0].split(" ");//複数行の場合
	var num2 = str[1].split(" ");//複数行の場合
	var x = Number(num[0]);
	var n = Number(num[1]);
	if (n===0){
		ans = x;
		}else{
			for(var i = 0;i<n;i++){
				num2[i]=Number(num2[i]);
			}
		num2 = num2.sort(compareFunc);
		tar=num2[0];
		ab[0] = Math.abs(num2[0]-x);
		for(var j= 0;j<n-1;j++){
			ab[j]=Math.abs(num2[j]-x);
			ab[j+1]=Math.abs(num2[j+1]-x);
			if(ab[j]>ab[j+1]){
				tar = num2[j+1];
			}
		}
		if (tar !== x){
			ans = tar;
		}else{
				while(flg2){
					tar2 =tar -c;
					tar3 =tar +c;
					for(var k = 0;k<n;k++){
						ans = tar2;
						if(tar2 === num2[k]){//一致
							ans = tar3;
							flg = true;
							break;
						}
					}
					if(flg){
						flg= false;
						for(var l = 0;l<n;l++){
							if(tar3 === num2[l]){//一致
								ans =0;	
								flg = true;
								break;
							}
						}
					}
					if(ans ===0){
						c++;
					}else{
						flg2 = false;
						}
				}
			}
		}
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function compareFunc(a, b) {
  return a - b;
}