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 = new int[N];
		for(int i = 0; i < N; i++) {
			p[i] = scan.nextInt();
		}
		int upper = X+1;
		int lower = X-1;
		int ans = -1;

		ans = judge(N, p, X);

		while (ans == -1) {
			ans = judge(N, p, lower);
			if (ans != -1) break;
			ans = judge(N, p, upper);
			upper++;
			lower--;
		}

		System.out.println(ans);
	}

	public static int judge(int N, int[] p, int k) {
		int f = 0;
		int ans = -1;

		for(int i = 0; i < N; i++) {
			if (k == p[i]) {
				f++;
				break;
			}
		}
		if (f == 0) {
			ans = k;
		}
		return ans;

	}

} 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 = new int[N];
		for(int i = 0; i < N; i++) {
			p[i] = scan.nextInt();
		}
		int upper = X+1;
		int lower = X-1;
		int ans = -1;

		ans = judge(N, p, X);

		while (ans == -1) {
			ans = judge(N, p, lower);
			if (ans != -1) break;
			ans = judge(N, p, upper);
			upper++;
			lower--;
		}

		System.out.println(ans);
	}

	public static int judge(int N, int[] p, int k) {
		int f = 0;
		int ans = -1;

		for(int i = 0; i < N; i++) {
			if (k == p[i]) {
				f++;
				break;
			}
		}
		if (f == 0) {
			ans = k;
		}
		return ans;

	}

} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();
		int N = scan.nextInt();
		int[] p = new int[N];
		for(int i = 0; i < N; i++) {
			p[i] = scan.nextInt();
		}
		int upper = X+1;
		int lower = X-1;
		int ans = -1;

		ans = judge(N, p, X);

		while (ans == -1) {
			ans = judge(N, p, lower);
			if (ans != -1) break;
			ans = judge(N, p, upper);
			upper++;
			lower--;
		}

		System.out.println(ans);
	} main {

		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();
		int N = scan.nextInt();
		int[] p = new int[N];
		for(int i = 0; i < N; i++) {
			p[i] = scan.nextInt();
		}
		int upper = X+1;
		int lower = X-1;
		int ans = -1;

		ans = judge(N, p, X);

		while (ans == -1) {
			ans = judge(N, p, lower);
			if (ans != -1) break;
			ans = judge(N, p, upper);
			upper++;
			lower--;
		}

		System.out.println(ans);
	} 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 = new int[N]; p new int[N] N for(int i = 0; i < N; i++) {
			p[i] = scan.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			p[i] = scan.nextInt();
		} {
			p[i] = scan.nextInt();
		} p[i] = scan.nextInt() p[i] p i scan.nextInt() scan.nextInt scan int upper = X+1; upper X+1 X 1 int lower = X-1; lower X-1 X 1 int ans = -1; ans -1 1 ans = judge(N, p, X) ans judge(N, p, X) judge N p X while (ans == -1) {
			ans = judge(N, p, lower);
			if (ans != -1) break;
			ans = judge(N, p, upper);
			upper++;
			lower--;
		} ans == -1 ans -1 1 {
			ans = judge(N, p, lower);
			if (ans != -1) break;
			ans = judge(N, p, upper);
			upper++;
			lower--;
		} ans = judge(N, p, lower) ans judge(N, p, lower) judge N p lower if (ans != -1) break; ans != -1 ans -1 1 break; ans = judge(N, p, upper) ans judge(N, p, upper) judge N p upper upper++ upper lower-- lower System.out.println(ans) System.out.println System.out System System.out ans String[] args args public static int judge(int N, int[] p, int k) {
		int f = 0;
		int ans = -1;

		for(int i = 0; i < N; i++) {
			if (k == p[i]) {
				f++;
				break;
			}
		}
		if (f == 0) {
			ans = k;
		}
		return ans;

	} judge {
		int f = 0;
		int ans = -1;

		for(int i = 0; i < N; i++) {
			if (k == p[i]) {
				f++;
				break;
			}
		}
		if (f == 0) {
			ans = k;
		}
		return ans;

	} int f = 0; f 0 int ans = -1; ans -1 1 for(int i = 0; i < N; i++) {
			if (k == p[i]) {
				f++;
				break;
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			if (k == p[i]) {
				f++;
				break;
			}
		} {
			if (k == p[i]) {
				f++;
				break;
			}
		} if (k == p[i]) {
				f++;
				break;
			} k == p[i] k p[i] p i {
				f++;
				break;
			} f++ f break; if (f == 0) {
			ans = k;
		} f == 0 f 0 {
			ans = k;
		} ans = k ans k return ans; ans int N N int[] p p int k k 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 = new int[N];
		for(int i = 0; i < N; i++) {
			p[i] = scan.nextInt();
		}
		int upper = X+1;
		int lower = X-1;
		int ans = -1;

		ans = judge(N, p, X);

		while (ans == -1) {
			ans = judge(N, p, lower);
			if (ans != -1) break;
			ans = judge(N, p, upper);
			upper++;
			lower--;
		}

		System.out.println(ans);
	}

	public static int judge(int N, int[] p, int k) {
		int f = 0;
		int ans = -1;

		for(int i = 0; i < N; i++) {
			if (k == p[i]) {
				f++;
				break;
			}
		}
		if (f == 0) {
			ans = k;
		}
		return ans;

	}

} 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 = new int[N];
		for(int i = 0; i < N; i++) {
			p[i] = scan.nextInt();
		}
		int upper = X+1;
		int lower = X-1;
		int ans = -1;

		ans = judge(N, p, X);

		while (ans == -1) {
			ans = judge(N, p, lower);
			if (ans != -1) break;
			ans = judge(N, p, upper);
			upper++;
			lower--;
		}

		System.out.println(ans);
	}

	public static int judge(int N, int[] p, int k) {
		int f = 0;
		int ans = -1;

		for(int i = 0; i < N; i++) {
			if (k == p[i]) {
				f++;
				break;
			}
		}
		if (f == 0) {
			ans = k;
		}
		return ans;

	}

} 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 = new int[N];
		for(int i = 0; i < N; i++) {
			p[i] = scan.nextInt();
		}
		int upper = X+1;
		int lower = X-1;
		int ans = -1;

		ans = judge(N, p, X);

		while (ans == -1) {
			ans = judge(N, p, lower);
			if (ans != -1) break;
			ans = judge(N, p, upper);
			upper++;
			lower--;
		}

		System.out.println(ans);
	}

	public static int judge(int N, int[] p, int k) {
		int f = 0;
		int ans = -1;

		for(int i = 0; i < N; i++) {
			if (k == p[i]) {
				f++;
				break;
			}
		}
		if (f == 0) {
			ans = k;
		}
		return ans;

	}

}