//package atcoder;
 
import java.util.*;
//import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int N = sc.nextInt();
		Integer p[] = new Integer [N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		/*for(int i=0;i<N;i++) {
			System.out.println(p[i]);
		}*/
	    int min=Integer.MAX_VALUE;
		for(int j=-1000;j<1000;j++) {
			if(Arrays.asList(p).contains(j)) {
				//System.out.println(j);
				continue;
			}
			//System.out.println(j);
		  min = Math.min(min, Math.abs(X-j));
		}
		int a = X-min;
		if(Arrays.asList(p).contains(a)) {
			System.out.println(X+min);
		}else {
			System.out.println(a);
		}
	}
} import java.util.*; util.* java public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int N = sc.nextInt();
		Integer p[] = new Integer [N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		/*for(int i=0;i<N;i++) {
			System.out.println(p[i]);
		}*/
	    int min=Integer.MAX_VALUE;
		for(int j=-1000;j<1000;j++) {
			if(Arrays.asList(p).contains(j)) {
				//System.out.println(j);
				continue;
			}
			//System.out.println(j);
		  min = Math.min(min, Math.abs(X-j));
		}
		int a = X-min;
		if(Arrays.asList(p).contains(a)) {
			System.out.println(X+min);
		}else {
			System.out.println(a);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int N = sc.nextInt();
		Integer p[] = new Integer [N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		/*for(int i=0;i<N;i++) {
			System.out.println(p[i]);
		}*/
	    int min=Integer.MAX_VALUE;
		for(int j=-1000;j<1000;j++) {
			if(Arrays.asList(p).contains(j)) {
				//System.out.println(j);
				continue;
			}
			//System.out.println(j);
		  min = Math.min(min, Math.abs(X-j));
		}
		int a = X-min;
		if(Arrays.asList(p).contains(a)) {
			System.out.println(X+min);
		}else {
			System.out.println(a);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int N = sc.nextInt();
		Integer p[] = new Integer [N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		/*for(int i=0;i<N;i++) {
			System.out.println(p[i]);
		}*/
	    int min=Integer.MAX_VALUE;
		for(int j=-1000;j<1000;j++) {
			if(Arrays.asList(p).contains(j)) {
				//System.out.println(j);
				continue;
			}
			//System.out.println(j);
		  min = Math.min(min, Math.abs(X-j));
		}
		int a = X-min;
		if(Arrays.asList(p).contains(a)) {
			System.out.println(X+min);
		}else {
			System.out.println(a);
		}
	} 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 Integer p[] = new Integer [N]; p new Integer [N] N 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 int min=Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int j=-1000;j<1000;j++) {
			if(Arrays.asList(p).contains(j)) {
				//System.out.println(j);
				continue;
			}
			//System.out.println(j);
		  min = Math.min(min, Math.abs(X-j));
		} int j=-1000; int j=-1000; j -1000 1000 j<1000 j 1000 j++ j++ j {
			if(Arrays.asList(p).contains(j)) {
				//System.out.println(j);
				continue;
			}
			//System.out.println(j);
		  min = Math.min(min, Math.abs(X-j));
		} {
			if(Arrays.asList(p).contains(j)) {
				//System.out.println(j);
				continue;
			}
			//System.out.println(j);
		  min = Math.min(min, Math.abs(X-j));
		} if(Arrays.asList(p).contains(j)) {
				//System.out.println(j);
				continue;
			} Arrays.asList(p).contains(j) Arrays.asList(p).contains Arrays.asList(p) Arrays.asList Arrays p j {
				//System.out.println(j);
				continue;
			} continue; min = Math.min(min, Math.abs(X-j)) min Math.min(min, Math.abs(X-j)) Math.min Math min Math.abs(X-j) Math.abs Math X-j X j int a = X-min; a X-min X min if(Arrays.asList(p).contains(a)) {
			System.out.println(X+min);
		}else {
			System.out.println(a);
		} Arrays.asList(p).contains(a) Arrays.asList(p).contains Arrays.asList(p) Arrays.asList Arrays p a {
			System.out.println(X+min);
		} System.out.println(X+min) System.out.println System.out System System.out X+min X min {
			System.out.println(a);
		} System.out.println(a) System.out.println System.out System System.out a String[] args args public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int N = sc.nextInt();
		Integer p[] = new Integer [N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		/*for(int i=0;i<N;i++) {
			System.out.println(p[i]);
		}*/
	    int min=Integer.MAX_VALUE;
		for(int j=-1000;j<1000;j++) {
			if(Arrays.asList(p).contains(j)) {
				//System.out.println(j);
				continue;
			}
			//System.out.println(j);
		  min = Math.min(min, Math.abs(X-j));
		}
		int a = X-min;
		if(Arrays.asList(p).contains(a)) {
			System.out.println(X+min);
		}else {
			System.out.println(a);
		}
	}
} public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int N = sc.nextInt();
		Integer p[] = new Integer [N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		/*for(int i=0;i<N;i++) {
			System.out.println(p[i]);
		}*/
	    int min=Integer.MAX_VALUE;
		for(int j=-1000;j<1000;j++) {
			if(Arrays.asList(p).contains(j)) {
				//System.out.println(j);
				continue;
			}
			//System.out.println(j);
		  min = Math.min(min, Math.abs(X-j));
		}
		int a = X-min;
		if(Arrays.asList(p).contains(a)) {
			System.out.println(X+min);
		}else {
			System.out.println(a);
		}
	}
} Main
//package atcoder;
 
import java.util.*;
//import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int N = sc.nextInt();
		Integer p[] = new Integer [N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		/*for(int i=0;i<N;i++) {
			System.out.println(p[i]);
		}*/
	    int min=Integer.MAX_VALUE;
		for(int j=-1000;j<1000;j++) {
			if(Arrays.asList(p).contains(j)) {
				//System.out.println(j);
				continue;
			}
			//System.out.println(j);
		  min = Math.min(min, Math.abs(X-j));
		}
		int a = X-min;
		if(Arrays.asList(p).contains(a)) {
			System.out.println(X+min);
		}else {
			System.out.println(a);
		}
	}
}