import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int X = s.nextInt();
		int N = s.nextInt();
		int[] p = new int[N];
		for(int i=0; i<N; i++) {
			p[i] = s.nextInt();
		}
		Arrays.sort(p); //昇順にソート
		int i_X =-1; //p[i] = X を満たす整数i
		boolean existX = false;
		for(int i =0; i<N; i++) {
			if(p[i] == X ) {existX = true; i_X = i; break;}
		}

		int ans=0;
		int sumP =0;
		for(int i=0; i<N; i++) {
			sumP += p[i];
		}
		
		if(!existX) {ans = X; }
		else if(sumP == (N*(p[N-1]+p[0]))/2 ) { 
			if(X-p[0] <= p[N-1]-X) {ans = p[0]-1;}
			else {ans = p[N-1]+1;}
		}
		else { boolean da = false;
			for(int k=1; k<=i_X && k<=N-1-i_X; k++ ) {

				  if(p[i_X-k] !=  p[i_X]-k) {ans =p[i_X]-k;  da = true; break;}
				  else if(p[i_X+k] !=  p[i_X]+k) {ans =p[i_X]+k; da = true; break;}
				}
			if(!da) {
				if(X-p[0] <= p[N-1]-X) {ans = 9;}
					else {ans = 9; }	
				
			}
		
		}
		
		System.out.println(ans);
	}

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int X = s.nextInt();
		int N = s.nextInt();
		int[] p = new int[N];
		for(int i=0; i<N; i++) {
			p[i] = s.nextInt();
		}
		Arrays.sort(p); //昇順にソート
		int i_X =-1; //p[i] = X を満たす整数i
		boolean existX = false;
		for(int i =0; i<N; i++) {
			if(p[i] == X ) {existX = true; i_X = i; break;}
		}

		int ans=0;
		int sumP =0;
		for(int i=0; i<N; i++) {
			sumP += p[i];
		}
		
		if(!existX) {ans = X; }
		else if(sumP == (N*(p[N-1]+p[0]))/2 ) { 
			if(X-p[0] <= p[N-1]-X) {ans = p[0]-1;}
			else {ans = p[N-1]+1;}
		}
		else { boolean da = false;
			for(int k=1; k<=i_X && k<=N-1-i_X; k++ ) {

				  if(p[i_X-k] !=  p[i_X]-k) {ans =p[i_X]-k;  da = true; break;}
				  else if(p[i_X+k] !=  p[i_X]+k) {ans =p[i_X]+k; da = true; break;}
				}
			if(!da) {
				if(X-p[0] <= p[N-1]-X) {ans = 9;}
					else {ans = 9; }	
				
			}
		
		}
		
		System.out.println(ans);
	}

} Main public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int X = s.nextInt();
		int N = s.nextInt();
		int[] p = new int[N];
		for(int i=0; i<N; i++) {
			p[i] = s.nextInt();
		}
		Arrays.sort(p); //昇順にソート
		int i_X =-1; //p[i] = X を満たす整数i
		boolean existX = false;
		for(int i =0; i<N; i++) {
			if(p[i] == X ) {existX = true; i_X = i; break;}
		}

		int ans=0;
		int sumP =0;
		for(int i=0; i<N; i++) {
			sumP += p[i];
		}
		
		if(!existX) {ans = X; }
		else if(sumP == (N*(p[N-1]+p[0]))/2 ) { 
			if(X-p[0] <= p[N-1]-X) {ans = p[0]-1;}
			else {ans = p[N-1]+1;}
		}
		else { boolean da = false;
			for(int k=1; k<=i_X && k<=N-1-i_X; k++ ) {

				  if(p[i_X-k] !=  p[i_X]-k) {ans =p[i_X]-k;  da = true; break;}
				  else if(p[i_X+k] !=  p[i_X]+k) {ans =p[i_X]+k; da = true; break;}
				}
			if(!da) {
				if(X-p[0] <= p[N-1]-X) {ans = 9;}
					else {ans = 9; }	
				
			}
		
		}
		
		System.out.println(ans);
	} main {
		Scanner s = new Scanner(System.in);
		int X = s.nextInt();
		int N = s.nextInt();
		int[] p = new int[N];
		for(int i=0; i<N; i++) {
			p[i] = s.nextInt();
		}
		Arrays.sort(p); //昇順にソート
		int i_X =-1; //p[i] = X を満たす整数i
		boolean existX = false;
		for(int i =0; i<N; i++) {
			if(p[i] == X ) {existX = true; i_X = i; break;}
		}

		int ans=0;
		int sumP =0;
		for(int i=0; i<N; i++) {
			sumP += p[i];
		}
		
		if(!existX) {ans = X; }
		else if(sumP == (N*(p[N-1]+p[0]))/2 ) { 
			if(X-p[0] <= p[N-1]-X) {ans = p[0]-1;}
			else {ans = p[N-1]+1;}
		}
		else { boolean da = false;
			for(int k=1; k<=i_X && k<=N-1-i_X; k++ ) {

				  if(p[i_X-k] !=  p[i_X]-k) {ans =p[i_X]-k;  da = true; break;}
				  else if(p[i_X+k] !=  p[i_X]+k) {ans =p[i_X]+k; da = true; break;}
				}
			if(!da) {
				if(X-p[0] <= p[N-1]-X) {ans = 9;}
					else {ans = 9; }	
				
			}
		
		}
		
		System.out.println(ans);
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) int X = s.nextInt(); X s.nextInt() s.nextInt s int N = s.nextInt(); N s.nextInt() s.nextInt s int[] p = new int[N]; p new int[N] N for(int i=0; i<N; i++) {
			p[i] = s.nextInt();
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			p[i] = s.nextInt();
		} {
			p[i] = s.nextInt();
		} p[i] = s.nextInt() p[i] p i s.nextInt() s.nextInt s Arrays.sort(p) Arrays.sort Arrays p int i_X =-1; i_X -1 1 boolean existX = false; existX false for(int i =0; i<N; i++) {
			if(p[i] == X ) {existX = true; i_X = i; break;}
		} int i =0; int i =0; i 0 i<N i N i++ i++ i {
			if(p[i] == X ) {existX = true; i_X = i; break;}
		} {
			if(p[i] == X ) {existX = true; i_X = i; break;}
		} if(p[i] == X ) {existX = true; i_X = i; break;} p[i] == X p[i] p i X {existX = true; i_X = i; break;} existX = true existX true i_X = i i_X i break; int ans=0; ans 0 int sumP =0; sumP 0 for(int i=0; i<N; i++) {
			sumP += p[i];
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			sumP += p[i];
		} {
			sumP += p[i];
		} sumP += p[i] sumP p[i] p i if(!existX) {ans = X; }
		else if(sumP == (N*(p[N-1]+p[0]))/2 ) { 
			if(X-p[0] <= p[N-1]-X) {ans = p[0]-1;}
			else {ans = p[N-1]+1;}
		}
		else { boolean da = false;
			for(int k=1; k<=i_X && k<=N-1-i_X; k++ ) {

				  if(p[i_X-k] !=  p[i_X]-k) {ans =p[i_X]-k;  da = true; break;}
				  else if(p[i_X+k] !=  p[i_X]+k) {ans =p[i_X]+k; da = true; break;}
				}
			if(!da) {
				if(X-p[0] <= p[N-1]-X) {ans = 9;}
					else {ans = 9; }	
				
			}
		
		} !existX existX {ans = X; } ans = X ans X if(sumP == (N*(p[N-1]+p[0]))/2 ) { 
			if(X-p[0] <= p[N-1]-X) {ans = p[0]-1;}
			else {ans = p[N-1]+1;}
		}
		else { boolean da = false;
			for(int k=1; k<=i_X && k<=N-1-i_X; k++ ) {

				  if(p[i_X-k] !=  p[i_X]-k) {ans =p[i_X]-k;  da = true; break;}
				  else if(p[i_X+k] !=  p[i_X]+k) {ans =p[i_X]+k; da = true; break;}
				}
			if(!da) {
				if(X-p[0] <= p[N-1]-X) {ans = 9;}
					else {ans = 9; }	
				
			}
		
		} sumP == (N*(p[N-1]+p[0]))/2 sumP (N*(p[N-1]+p[0]))/2 (N*(p[N-1]+p[0])) N (p[N-1]+p[0]) p[N-1] p N-1 N 1 p[0] p 0 2 { 
			if(X-p[0] <= p[N-1]-X) {ans = p[0]-1;}
			else {ans = p[N-1]+1;}
		} if(X-p[0] <= p[N-1]-X) {ans = p[0]-1;}
			else {ans = p[N-1]+1;} X-p[0] <= p[N-1]-X X-p[0] X p[0] p 0 p[N-1]-X p[N-1] p N-1 N 1 X {ans = p[0]-1;} ans = p[0]-1 ans p[0]-1 p[0] p 0 1 {ans = p[N-1]+1;} ans = p[N-1]+1 ans p[N-1]+1 p[N-1] p N-1 N 1 1 { boolean da = false;
			for(int k=1; k<=i_X && k<=N-1-i_X; k++ ) {

				  if(p[i_X-k] !=  p[i_X]-k) {ans =p[i_X]-k;  da = true; break;}
				  else if(p[i_X+k] !=  p[i_X]+k) {ans =p[i_X]+k; da = true; break;}
				}
			if(!da) {
				if(X-p[0] <= p[N-1]-X) {ans = 9;}
					else {ans = 9; }	
				
			}
		
		} boolean da = false; da false for(int k=1; k<=i_X && k<=N-1-i_X; k++ ) {

				  if(p[i_X-k] !=  p[i_X]-k) {ans =p[i_X]-k;  da = true; break;}
				  else if(p[i_X+k] !=  p[i_X]+k) {ans =p[i_X]+k; da = true; break;}
				} int k=1; int k=1; k 1 k<=i_X && k<=N-1-i_X k<=i_X k i_X k<=N-1-i_X k N-1-i_X N-1-i_X N 1 i_X k++ k++ k {

				  if(p[i_X-k] !=  p[i_X]-k) {ans =p[i_X]-k;  da = true; break;}
				  else if(p[i_X+k] !=  p[i_X]+k) {ans =p[i_X]+k; da = true; break;}
				} {

				  if(p[i_X-k] !=  p[i_X]-k) {ans =p[i_X]-k;  da = true; break;}
				  else if(p[i_X+k] !=  p[i_X]+k) {ans =p[i_X]+k; da = true; break;}
				} if(p[i_X-k] !=  p[i_X]-k) {ans =p[i_X]-k;  da = true; break;}
				  else if(p[i_X+k] !=  p[i_X]+k) {ans =p[i_X]+k; da = true; break;} p[i_X-k] !=  p[i_X]-k p[i_X-k] p i_X-k i_X k p[i_X]-k p[i_X] p i_X k {ans =p[i_X]-k;  da = true; break;} ans =p[i_X]-k ans p[i_X]-k p[i_X] p i_X k da = true da true break; if(p[i_X+k] !=  p[i_X]+k) {ans =p[i_X]+k; da = true; break;} p[i_X+k] !=  p[i_X]+k p[i_X+k] p i_X+k i_X k p[i_X]+k p[i_X] p i_X k {ans =p[i_X]+k; da = true; break;} ans =p[i_X]+k ans p[i_X]+k p[i_X] p i_X k da = true da true break; if(!da) {
				if(X-p[0] <= p[N-1]-X) {ans = 9;}
					else {ans = 9; }	
				
			} !da da {
				if(X-p[0] <= p[N-1]-X) {ans = 9;}
					else {ans = 9; }	
				
			} if(X-p[0] <= p[N-1]-X) {ans = 9;}
					else {ans = 9; } X-p[0] <= p[N-1]-X X-p[0] X p[0] p 0 p[N-1]-X p[N-1] p N-1 N 1 X {ans = 9;} ans = 9 ans 9 {ans = 9; } ans = 9 ans 9 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int X = s.nextInt();
		int N = s.nextInt();
		int[] p = new int[N];
		for(int i=0; i<N; i++) {
			p[i] = s.nextInt();
		}
		Arrays.sort(p); //昇順にソート
		int i_X =-1; //p[i] = X を満たす整数i
		boolean existX = false;
		for(int i =0; i<N; i++) {
			if(p[i] == X ) {existX = true; i_X = i; break;}
		}

		int ans=0;
		int sumP =0;
		for(int i=0; i<N; i++) {
			sumP += p[i];
		}
		
		if(!existX) {ans = X; }
		else if(sumP == (N*(p[N-1]+p[0]))/2 ) { 
			if(X-p[0] <= p[N-1]-X) {ans = p[0]-1;}
			else {ans = p[N-1]+1;}
		}
		else { boolean da = false;
			for(int k=1; k<=i_X && k<=N-1-i_X; k++ ) {

				  if(p[i_X-k] !=  p[i_X]-k) {ans =p[i_X]-k;  da = true; break;}
				  else if(p[i_X+k] !=  p[i_X]+k) {ans =p[i_X]+k; da = true; break;}
				}
			if(!da) {
				if(X-p[0] <= p[N-1]-X) {ans = 9;}
					else {ans = 9; }	
				
			}
		
		}
		
		System.out.println(ans);
	}

} public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int X = s.nextInt();
		int N = s.nextInt();
		int[] p = new int[N];
		for(int i=0; i<N; i++) {
			p[i] = s.nextInt();
		}
		Arrays.sort(p); //昇順にソート
		int i_X =-1; //p[i] = X を満たす整数i
		boolean existX = false;
		for(int i =0; i<N; i++) {
			if(p[i] == X ) {existX = true; i_X = i; break;}
		}

		int ans=0;
		int sumP =0;
		for(int i=0; i<N; i++) {
			sumP += p[i];
		}
		
		if(!existX) {ans = X; }
		else if(sumP == (N*(p[N-1]+p[0]))/2 ) { 
			if(X-p[0] <= p[N-1]-X) {ans = p[0]-1;}
			else {ans = p[N-1]+1;}
		}
		else { boolean da = false;
			for(int k=1; k<=i_X && k<=N-1-i_X; k++ ) {

				  if(p[i_X-k] !=  p[i_X]-k) {ans =p[i_X]-k;  da = true; break;}
				  else if(p[i_X+k] !=  p[i_X]+k) {ans =p[i_X]+k; da = true; break;}
				}
			if(!da) {
				if(X-p[0] <= p[N-1]-X) {ans = 9;}
					else {ans = 9; }	
				
			}
		
		}
		
		System.out.println(ans);
	}

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int X = s.nextInt();
		int N = s.nextInt();
		int[] p = new int[N];
		for(int i=0; i<N; i++) {
			p[i] = s.nextInt();
		}
		Arrays.sort(p); //昇順にソート
		int i_X =-1; //p[i] = X を満たす整数i
		boolean existX = false;
		for(int i =0; i<N; i++) {
			if(p[i] == X ) {existX = true; i_X = i; break;}
		}

		int ans=0;
		int sumP =0;
		for(int i=0; i<N; i++) {
			sumP += p[i];
		}
		
		if(!existX) {ans = X; }
		else if(sumP == (N*(p[N-1]+p[0]))/2 ) { 
			if(X-p[0] <= p[N-1]-X) {ans = p[0]-1;}
			else {ans = p[N-1]+1;}
		}
		else { boolean da = false;
			for(int k=1; k<=i_X && k<=N-1-i_X; k++ ) {

				  if(p[i_X-k] !=  p[i_X]-k) {ans =p[i_X]-k;  da = true; break;}
				  else if(p[i_X+k] !=  p[i_X]+k) {ans =p[i_X]+k; da = true; break;}
				}
			if(!da) {
				if(X-p[0] <= p[N-1]-X) {ans = 9;}
					else {ans = 9; }	
				
			}
		
		}
		
		System.out.println(ans);
	}

}