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

public class Main {

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

		int x = in.nextInt();
		int n = in.nextInt();
		Integer a[] = new Integer[n];

		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}

		int c = 0;


		while(true) {
			if(Arrays.asList(a).contains(x-c)&&Arrays.asList(a).contains(x+c)) {
				c++;
				continue;
			}else {
				break;
			}
		}

		if(Arrays.asList(a).contains(x-c)) {
			System.out.println(x+c);
		}else {
			System.out.println(x-c);
		}


	}

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

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

		int x = in.nextInt();
		int n = in.nextInt();
		Integer a[] = new Integer[n];

		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}

		int c = 0;


		while(true) {
			if(Arrays.asList(a).contains(x-c)&&Arrays.asList(a).contains(x+c)) {
				c++;
				continue;
			}else {
				break;
			}
		}

		if(Arrays.asList(a).contains(x-c)) {
			System.out.println(x+c);
		}else {
			System.out.println(x-c);
		}


	}

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

		int x = in.nextInt();
		int n = in.nextInt();
		Integer a[] = new Integer[n];

		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}

		int c = 0;


		while(true) {
			if(Arrays.asList(a).contains(x-c)&&Arrays.asList(a).contains(x+c)) {
				c++;
				continue;
			}else {
				break;
			}
		}

		if(Arrays.asList(a).contains(x-c)) {
			System.out.println(x+c);
		}else {
			System.out.println(x-c);
		}


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

		int x = in.nextInt();
		int n = in.nextInt();
		Integer a[] = new Integer[n];

		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}

		int c = 0;


		while(true) {
			if(Arrays.asList(a).contains(x-c)&&Arrays.asList(a).contains(x+c)) {
				c++;
				continue;
			}else {
				break;
			}
		}

		if(Arrays.asList(a).contains(x-c)) {
			System.out.println(x+c);
		}else {
			System.out.println(x-c);
		}


	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int x = in.nextInt(); x in.nextInt() in.nextInt in int n = in.nextInt(); n in.nextInt() in.nextInt in Integer a[] = new Integer[n]; a new Integer[n] n for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			a[i] = in.nextInt();
		} {
			a[i] = in.nextInt();
		} a[i] = in.nextInt() a[i] a i in.nextInt() in.nextInt in int c = 0; c 0 while(true) {
			if(Arrays.asList(a).contains(x-c)&&Arrays.asList(a).contains(x+c)) {
				c++;
				continue;
			}else {
				break;
			}
		} true {
			if(Arrays.asList(a).contains(x-c)&&Arrays.asList(a).contains(x+c)) {
				c++;
				continue;
			}else {
				break;
			}
		} if(Arrays.asList(a).contains(x-c)&&Arrays.asList(a).contains(x+c)) {
				c++;
				continue;
			}else {
				break;
			} Arrays.asList(a).contains(x-c)&&Arrays.asList(a).contains(x+c) Arrays.asList(a).contains(x-c) Arrays.asList(a).contains Arrays.asList(a) Arrays.asList Arrays a x-c x c Arrays.asList(a).contains(x+c) Arrays.asList(a).contains Arrays.asList(a) Arrays.asList Arrays a x+c x c {
				c++;
				continue;
			} c++ c continue; {
				break;
			} break; if(Arrays.asList(a).contains(x-c)) {
			System.out.println(x+c);
		}else {
			System.out.println(x-c);
		} Arrays.asList(a).contains(x-c) Arrays.asList(a).contains Arrays.asList(a) Arrays.asList Arrays a x-c x c {
			System.out.println(x+c);
		} System.out.println(x+c) System.out.println System.out System System.out x+c x c {
			System.out.println(x-c);
		} System.out.println(x-c) System.out.println System.out System System.out x-c x c String[] args args public class Main {

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

		int x = in.nextInt();
		int n = in.nextInt();
		Integer a[] = new Integer[n];

		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}

		int c = 0;


		while(true) {
			if(Arrays.asList(a).contains(x-c)&&Arrays.asList(a).contains(x+c)) {
				c++;
				continue;
			}else {
				break;
			}
		}

		if(Arrays.asList(a).contains(x-c)) {
			System.out.println(x+c);
		}else {
			System.out.println(x-c);
		}


	}

} public class Main {

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

		int x = in.nextInt();
		int n = in.nextInt();
		Integer a[] = new Integer[n];

		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}

		int c = 0;


		while(true) {
			if(Arrays.asList(a).contains(x-c)&&Arrays.asList(a).contains(x+c)) {
				c++;
				continue;
			}else {
				break;
			}
		}

		if(Arrays.asList(a).contains(x-c)) {
			System.out.println(x+c);
		}else {
			System.out.println(x-c);
		}


	}

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

public class Main {

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

		int x = in.nextInt();
		int n = in.nextInt();
		Integer a[] = new Integer[n];

		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}

		int c = 0;


		while(true) {
			if(Arrays.asList(a).contains(x-c)&&Arrays.asList(a).contains(x+c)) {
				c++;
				continue;
			}else {
				break;
			}
		}

		if(Arrays.asList(a).contains(x-c)) {
			System.out.println(x+c);
		}else {
			System.out.println(x-c);
		}


	}

}
