import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();
		int N = scan.nextInt();
		int p = 0;
		int min;
		int max;
		int[] result = new int[N];

		if(N == 0) {
			System.out.println(X);
			System.exit(0);
		}

		for(int i = 0;i < N;i++) {
			p = scan.nextInt();
			result[i] = p;
		}

		for(int i = 0;;i++) {
			min = X - i;
			for(int j = 0;j < N;j++) {
				if(result[j] == min) {
					break;
				}else if(j == N - 1) {
					System.out.println(min);
					System.exit(0);
				}
			}
			max = X + i;
			for(int j = 0;j < N;j++) {
				if(result[j] == max) {
					break;
				}else if(j == N - 1) {
					System.out.println(max);
					System.exit(0);
				}
			}
		}

	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();
		int N = scan.nextInt();
		int p = 0;
		int min;
		int max;
		int[] result = new int[N];

		if(N == 0) {
			System.out.println(X);
			System.exit(0);
		}

		for(int i = 0;i < N;i++) {
			p = scan.nextInt();
			result[i] = p;
		}

		for(int i = 0;;i++) {
			min = X - i;
			for(int j = 0;j < N;j++) {
				if(result[j] == min) {
					break;
				}else if(j == N - 1) {
					System.out.println(min);
					System.exit(0);
				}
			}
			max = X + i;
			for(int j = 0;j < N;j++) {
				if(result[j] == max) {
					break;
				}else if(j == N - 1) {
					System.out.println(max);
					System.exit(0);
				}
			}
		}

	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();
		int N = scan.nextInt();
		int p = 0;
		int min;
		int max;
		int[] result = new int[N];

		if(N == 0) {
			System.out.println(X);
			System.exit(0);
		}

		for(int i = 0;i < N;i++) {
			p = scan.nextInt();
			result[i] = p;
		}

		for(int i = 0;;i++) {
			min = X - i;
			for(int j = 0;j < N;j++) {
				if(result[j] == min) {
					break;
				}else if(j == N - 1) {
					System.out.println(min);
					System.exit(0);
				}
			}
			max = X + i;
			for(int j = 0;j < N;j++) {
				if(result[j] == max) {
					break;
				}else if(j == N - 1) {
					System.out.println(max);
					System.exit(0);
				}
			}
		}

	} main {
		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();
		int N = scan.nextInt();
		int p = 0;
		int min;
		int max;
		int[] result = new int[N];

		if(N == 0) {
			System.out.println(X);
			System.exit(0);
		}

		for(int i = 0;i < N;i++) {
			p = scan.nextInt();
			result[i] = p;
		}

		for(int i = 0;;i++) {
			min = X - i;
			for(int j = 0;j < N;j++) {
				if(result[j] == min) {
					break;
				}else if(j == N - 1) {
					System.out.println(min);
					System.exit(0);
				}
			}
			max = X + i;
			for(int j = 0;j < N;j++) {
				if(result[j] == max) {
					break;
				}else if(j == N - 1) {
					System.out.println(max);
					System.exit(0);
				}
			}
		}

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int X = scan.nextInt(); X scan.nextInt() scan.nextInt scan int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int p = 0; p 0 int min; min int max; max int[] result = new int[N]; result new int[N] N if(N == 0) {
			System.out.println(X);
			System.exit(0);
		} N == 0 N 0 {
			System.out.println(X);
			System.exit(0);
		} System.out.println(X) System.out.println System.out System System.out X System.exit(0) System.exit System 0 for(int i = 0;i < N;i++) {
			p = scan.nextInt();
			result[i] = p;
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			p = scan.nextInt();
			result[i] = p;
		} {
			p = scan.nextInt();
			result[i] = p;
		} p = scan.nextInt() p scan.nextInt() scan.nextInt scan result[i] = p result[i] result i p for(int i = 0;;i++) {
			min = X - i;
			for(int j = 0;j < N;j++) {
				if(result[j] == min) {
					break;
				}else if(j == N - 1) {
					System.out.println(min);
					System.exit(0);
				}
			}
			max = X + i;
			for(int j = 0;j < N;j++) {
				if(result[j] == max) {
					break;
				}else if(j == N - 1) {
					System.out.println(max);
					System.exit(0);
				}
			}
		} int i = 0; int i = 0; i 0 i++ i++ i {
			min = X - i;
			for(int j = 0;j < N;j++) {
				if(result[j] == min) {
					break;
				}else if(j == N - 1) {
					System.out.println(min);
					System.exit(0);
				}
			}
			max = X + i;
			for(int j = 0;j < N;j++) {
				if(result[j] == max) {
					break;
				}else if(j == N - 1) {
					System.out.println(max);
					System.exit(0);
				}
			}
		} {
			min = X - i;
			for(int j = 0;j < N;j++) {
				if(result[j] == min) {
					break;
				}else if(j == N - 1) {
					System.out.println(min);
					System.exit(0);
				}
			}
			max = X + i;
			for(int j = 0;j < N;j++) {
				if(result[j] == max) {
					break;
				}else if(j == N - 1) {
					System.out.println(max);
					System.exit(0);
				}
			}
		} min = X - i min X - i X i for(int j = 0;j < N;j++) {
				if(result[j] == min) {
					break;
				}else if(j == N - 1) {
					System.out.println(min);
					System.exit(0);
				}
			} int j = 0; int j = 0; j 0 j < N j N j++ j++ j {
				if(result[j] == min) {
					break;
				}else if(j == N - 1) {
					System.out.println(min);
					System.exit(0);
				}
			} {
				if(result[j] == min) {
					break;
				}else if(j == N - 1) {
					System.out.println(min);
					System.exit(0);
				}
			} if(result[j] == min) {
					break;
				}else if(j == N - 1) {
					System.out.println(min);
					System.exit(0);
				} result[j] == min result[j] result j min {
					break;
				} break; if(j == N - 1) {
					System.out.println(min);
					System.exit(0);
				} j == N - 1 j N - 1 N 1 {
					System.out.println(min);
					System.exit(0);
				} System.out.println(min) System.out.println System.out System System.out min System.exit(0) System.exit System 0 max = X + i max X + i X i for(int j = 0;j < N;j++) {
				if(result[j] == max) {
					break;
				}else if(j == N - 1) {
					System.out.println(max);
					System.exit(0);
				}
			} int j = 0; int j = 0; j 0 j < N j N j++ j++ j {
				if(result[j] == max) {
					break;
				}else if(j == N - 1) {
					System.out.println(max);
					System.exit(0);
				}
			} {
				if(result[j] == max) {
					break;
				}else if(j == N - 1) {
					System.out.println(max);
					System.exit(0);
				}
			} if(result[j] == max) {
					break;
				}else if(j == N - 1) {
					System.out.println(max);
					System.exit(0);
				} result[j] == max result[j] result j max {
					break;
				} break; if(j == N - 1) {
					System.out.println(max);
					System.exit(0);
				} j == N - 1 j N - 1 N 1 {
					System.out.println(max);
					System.exit(0);
				} System.out.println(max) System.out.println System.out System System.out max System.exit(0) System.exit System 0 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();
		int N = scan.nextInt();
		int p = 0;
		int min;
		int max;
		int[] result = new int[N];

		if(N == 0) {
			System.out.println(X);
			System.exit(0);
		}

		for(int i = 0;i < N;i++) {
			p = scan.nextInt();
			result[i] = p;
		}

		for(int i = 0;;i++) {
			min = X - i;
			for(int j = 0;j < N;j++) {
				if(result[j] == min) {
					break;
				}else if(j == N - 1) {
					System.out.println(min);
					System.exit(0);
				}
			}
			max = X + i;
			for(int j = 0;j < N;j++) {
				if(result[j] == max) {
					break;
				}else if(j == N - 1) {
					System.out.println(max);
					System.exit(0);
				}
			}
		}

	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();
		int N = scan.nextInt();
		int p = 0;
		int min;
		int max;
		int[] result = new int[N];

		if(N == 0) {
			System.out.println(X);
			System.exit(0);
		}

		for(int i = 0;i < N;i++) {
			p = scan.nextInt();
			result[i] = p;
		}

		for(int i = 0;;i++) {
			min = X - i;
			for(int j = 0;j < N;j++) {
				if(result[j] == min) {
					break;
				}else if(j == N - 1) {
					System.out.println(min);
					System.exit(0);
				}
			}
			max = X + i;
			for(int j = 0;j < N;j++) {
				if(result[j] == max) {
					break;
				}else if(j == N - 1) {
					System.out.println(max);
					System.exit(0);
				}
			}
		}

	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();
		int N = scan.nextInt();
		int p = 0;
		int min;
		int max;
		int[] result = new int[N];

		if(N == 0) {
			System.out.println(X);
			System.exit(0);
		}

		for(int i = 0;i < N;i++) {
			p = scan.nextInt();
			result[i] = p;
		}

		for(int i = 0;;i++) {
			min = X - i;
			for(int j = 0;j < N;j++) {
				if(result[j] == min) {
					break;
				}else if(j == N - 1) {
					System.out.println(min);
					System.exit(0);
				}
			}
			max = X + i;
			for(int j = 0;j < N;j++) {
				if(result[j] == max) {
					break;
				}else if(j == N - 1) {
					System.out.println(max);
					System.exit(0);
				}
			}
		}

	}
}