import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        int[] p = new int[N];
        boolean[] q = new boolean[102];
        for(int i=0; i<N; i++){
            p[i]=sc.nextInt();
            q[p[i]] = true;
        }

        int res=X;
        for(int i=0; i<X+1; i++){
            if(!q[X-i]){
                res=X-i;
                System.out.println(res);
                return;
            }
            if(!q[X+i]){
                res=X+i;
                System.out.println(res);
                return;
            }
        }
        if(X>50){
            res=101;
        }else{
            res=-1;
        }
        System.out.println(res);
        
    
        }
    } 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();
        int[] p = new int[N];
        boolean[] q = new boolean[102];
        for(int i=0; i<N; i++){
            p[i]=sc.nextInt();
            q[p[i]] = true;
        }

        int res=X;
        for(int i=0; i<X+1; i++){
            if(!q[X-i]){
                res=X-i;
                System.out.println(res);
                return;
            }
            if(!q[X+i]){
                res=X+i;
                System.out.println(res);
                return;
            }
        }
        if(X>50){
            res=101;
        }else{
            res=-1;
        }
        System.out.println(res);
        
    
        }
    } Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        int[] p = new int[N];
        boolean[] q = new boolean[102];
        for(int i=0; i<N; i++){
            p[i]=sc.nextInt();
            q[p[i]] = true;
        }

        int res=X;
        for(int i=0; i<X+1; i++){
            if(!q[X-i]){
                res=X-i;
                System.out.println(res);
                return;
            }
            if(!q[X+i]){
                res=X+i;
                System.out.println(res);
                return;
            }
        }
        if(X>50){
            res=101;
        }else{
            res=-1;
        }
        System.out.println(res);
        
    
        } main {
		Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        int[] p = new int[N];
        boolean[] q = new boolean[102];
        for(int i=0; i<N; i++){
            p[i]=sc.nextInt();
            q[p[i]] = true;
        }

        int res=X;
        for(int i=0; i<X+1; i++){
            if(!q[X-i]){
                res=X-i;
                System.out.println(res);
                return;
            }
            if(!q[X+i]){
                res=X+i;
                System.out.println(res);
                return;
            }
        }
        if(X>50){
            res=101;
        }else{
            res=-1;
        }
        System.out.println(res);
        
    
        } 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 boolean[] q = new boolean[102]; q new boolean[102] 102 for(int i=0; i<N; i++){
            p[i]=sc.nextInt();
            q[p[i]] = true;
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            p[i]=sc.nextInt();
            q[p[i]] = true;
        } {
            p[i]=sc.nextInt();
            q[p[i]] = true;
        } p[i]=sc.nextInt() p[i] p i sc.nextInt() sc.nextInt sc q[p[i]] = true q[p[i]] q p[i] p i true int res=X; res X for(int i=0; i<X+1; i++){
            if(!q[X-i]){
                res=X-i;
                System.out.println(res);
                return;
            }
            if(!q[X+i]){
                res=X+i;
                System.out.println(res);
                return;
            }
        } int i=0; int i=0; i 0 i<X+1 i X+1 X 1 i++ i++ i {
            if(!q[X-i]){
                res=X-i;
                System.out.println(res);
                return;
            }
            if(!q[X+i]){
                res=X+i;
                System.out.println(res);
                return;
            }
        } {
            if(!q[X-i]){
                res=X-i;
                System.out.println(res);
                return;
            }
            if(!q[X+i]){
                res=X+i;
                System.out.println(res);
                return;
            }
        } if(!q[X-i]){
                res=X-i;
                System.out.println(res);
                return;
            } !q[X-i] q[X-i] q X-i X i {
                res=X-i;
                System.out.println(res);
                return;
            } res=X-i res X-i X i System.out.println(res) System.out.println System.out System System.out res return; if(!q[X+i]){
                res=X+i;
                System.out.println(res);
                return;
            } !q[X+i] q[X+i] q X+i X i {
                res=X+i;
                System.out.println(res);
                return;
            } res=X+i res X+i X i System.out.println(res) System.out.println System.out System System.out res return; if(X>50){
            res=101;
        }else{
            res=-1;
        } X>50 X 50 {
            res=101;
        } res=101 res 101 {
            res=-1;
        } res=-1 res -1 1 System.out.println(res) System.out.println System.out System System.out res 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();
        int[] p = new int[N];
        boolean[] q = new boolean[102];
        for(int i=0; i<N; i++){
            p[i]=sc.nextInt();
            q[p[i]] = true;
        }

        int res=X;
        for(int i=0; i<X+1; i++){
            if(!q[X-i]){
                res=X-i;
                System.out.println(res);
                return;
            }
            if(!q[X+i]){
                res=X+i;
                System.out.println(res);
                return;
            }
        }
        if(X>50){
            res=101;
        }else{
            res=-1;
        }
        System.out.println(res);
        
    
        }
    } public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        int[] p = new int[N];
        boolean[] q = new boolean[102];
        for(int i=0; i<N; i++){
            p[i]=sc.nextInt();
            q[p[i]] = true;
        }

        int res=X;
        for(int i=0; i<X+1; i++){
            if(!q[X-i]){
                res=X-i;
                System.out.println(res);
                return;
            }
            if(!q[X+i]){
                res=X+i;
                System.out.println(res);
                return;
            }
        }
        if(X>50){
            res=101;
        }else{
            res=-1;
        }
        System.out.println(res);
        
    
        }
    } Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        int[] p = new int[N];
        boolean[] q = new boolean[102];
        for(int i=0; i<N; i++){
            p[i]=sc.nextInt();
            q[p[i]] = true;
        }

        int res=X;
        for(int i=0; i<X+1; i++){
            if(!q[X-i]){
                res=X-i;
                System.out.println(res);
                return;
            }
            if(!q[X+i]){
                res=X+i;
                System.out.println(res);
                return;
            }
        }
        if(X>50){
            res=101;
        }else{
            res=-1;
        }
        System.out.println(res);
        
    
        }
    }