import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int N = sc.nextInt();
		int p[] = new int[N];

		int a = X;
		int ans1 = X;
		int ans2 = X;
		int s = 0;

		for(int i = 0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans1 = X;
				break;
			}
			s=0;
			X = X-1;
		}
		X=a;
		s=0;
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans2 = X;
				break;
			}
			s=0;
			X = X+1;
		}

		X=a-ans1;
		N=ans2-a;

		if(X<=N) {
			System.out.println(ans1);
		}else {
			System.out.println(ans2);
		}

	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int N = sc.nextInt();
		int p[] = new int[N];

		int a = X;
		int ans1 = X;
		int ans2 = X;
		int s = 0;

		for(int i = 0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans1 = X;
				break;
			}
			s=0;
			X = X-1;
		}
		X=a;
		s=0;
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans2 = X;
				break;
			}
			s=0;
			X = X+1;
		}

		X=a-ans1;
		N=ans2-a;

		if(X<=N) {
			System.out.println(ans1);
		}else {
			System.out.println(ans2);
		}

	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int N = sc.nextInt();
		int p[] = new int[N];

		int a = X;
		int ans1 = X;
		int ans2 = X;
		int s = 0;

		for(int i = 0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans1 = X;
				break;
			}
			s=0;
			X = X-1;
		}
		X=a;
		s=0;
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans2 = X;
				break;
			}
			s=0;
			X = X+1;
		}

		X=a-ans1;
		N=ans2-a;

		if(X<=N) {
			System.out.println(ans1);
		}else {
			System.out.println(ans2);
		}

	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int N = sc.nextInt();
		int p[] = new int[N];

		int a = X;
		int ans1 = X;
		int ans2 = X;
		int s = 0;

		for(int i = 0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans1 = X;
				break;
			}
			s=0;
			X = X-1;
		}
		X=a;
		s=0;
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans2 = X;
				break;
			}
			s=0;
			X = X+1;
		}

		X=a-ans1;
		N=ans2-a;

		if(X<=N) {
			System.out.println(ans1);
		}else {
			System.out.println(ans2);
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int p[] = new int[N]; p new int[N] N int a = X; a X int ans1 = X; ans1 X int ans2 = X; ans2 X int s = 0; s 0 for(int i = 0;i<N;i++) {
			p[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i<N i N i++ i++ i {
			p[i] = sc.nextInt();
		} {
			p[i] = sc.nextInt();
		} p[i] = sc.nextInt() p[i] p i sc.nextInt() sc.nextInt sc for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans1 = X;
				break;
			}
			s=0;
			X = X-1;
		} int i = 0 ; int i = 0 ; i 0 i<N+1 i N+1 N 1 i++ i++ i {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans1 = X;
				break;
			}
			s=0;
			X = X-1;
		} {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans1 = X;
				break;
			}
			s=0;
			X = X-1;
		} for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			} int j = 0; int j = 0; j 0 j<N j N j++ j++ j {
				if(p[j]!=X) {
					s++;
				}
			} {
				if(p[j]!=X) {
					s++;
				}
			} if(p[j]!=X) {
					s++;
				} p[j]!=X p[j] p j X {
					s++;
				} s++ s if(s==N) {
				ans1 = X;
				break;
			} s==N s N {
				ans1 = X;
				break;
			} ans1 = X ans1 X break; s=0 s 0 X = X-1 X X-1 X 1 X=a X a s=0 s 0 for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans2 = X;
				break;
			}
			s=0;
			X = X+1;
		} int i = 0 ; int i = 0 ; i 0 i<N+1 i N+1 N 1 i++ i++ i {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans2 = X;
				break;
			}
			s=0;
			X = X+1;
		} {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans2 = X;
				break;
			}
			s=0;
			X = X+1;
		} for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			} int j = 0; int j = 0; j 0 j<N j N j++ j++ j {
				if(p[j]!=X) {
					s++;
				}
			} {
				if(p[j]!=X) {
					s++;
				}
			} if(p[j]!=X) {
					s++;
				} p[j]!=X p[j] p j X {
					s++;
				} s++ s if(s==N) {
				ans2 = X;
				break;
			} s==N s N {
				ans2 = X;
				break;
			} ans2 = X ans2 X break; s=0 s 0 X = X+1 X X+1 X 1 X=a-ans1 X a-ans1 a ans1 N=ans2-a N ans2-a ans2 a if(X<=N) {
			System.out.println(ans1);
		}else {
			System.out.println(ans2);
		} X<=N X N {
			System.out.println(ans1);
		} System.out.println(ans1) System.out.println System.out System System.out ans1 {
			System.out.println(ans2);
		} System.out.println(ans2) System.out.println System.out System System.out ans2 String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int N = sc.nextInt();
		int p[] = new int[N];

		int a = X;
		int ans1 = X;
		int ans2 = X;
		int s = 0;

		for(int i = 0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans1 = X;
				break;
			}
			s=0;
			X = X-1;
		}
		X=a;
		s=0;
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans2 = X;
				break;
			}
			s=0;
			X = X+1;
		}

		X=a-ans1;
		N=ans2-a;

		if(X<=N) {
			System.out.println(ans1);
		}else {
			System.out.println(ans2);
		}

	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int N = sc.nextInt();
		int p[] = new int[N];

		int a = X;
		int ans1 = X;
		int ans2 = X;
		int s = 0;

		for(int i = 0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans1 = X;
				break;
			}
			s=0;
			X = X-1;
		}
		X=a;
		s=0;
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans2 = X;
				break;
			}
			s=0;
			X = X+1;
		}

		X=a-ans1;
		N=ans2-a;

		if(X<=N) {
			System.out.println(ans1);
		}else {
			System.out.println(ans2);
		}

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int N = sc.nextInt();
		int p[] = new int[N];

		int a = X;
		int ans1 = X;
		int ans2 = X;
		int s = 0;

		for(int i = 0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans1 = X;
				break;
			}
			s=0;
			X = X-1;
		}
		X=a;
		s=0;
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans2 = X;
				break;
			}
			s=0;
			X = X+1;
		}

		X=a-ans1;
		N=ans2-a;

		if(X<=N) {
			System.out.println(ans1);
		}else {
			System.out.println(ans2);
		}

	}

}
