import java.util.*;
import java.io.*;
import java.math.*;
public class Main{

	public static void main(String args[]){
		FastReader sc = new FastReader();
		StringBuilder sb=new StringBuilder();
		int t,i,n,x;
		t=1;
		while(t-->0){
            x=sc.nextInt();
            n=sc.nextInt();
            int a[]=new int[n];
            HashSet<Integer> set=new HashSet<>();
            for(i=0;i<n;i++){
                a[i]=sc.nextInt();
                set.add(a[i]);
            }
            int temp=x;
            int min=Integer.MAX_VALUE;
            int num=x;
            while(true){
                int val=x-temp;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp--;
            }
            temp=x;
            while(true){
                int val=temp-x;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp++;
            }
            sb.append(num).append('\n');
		}
		sb.deleteCharAt(sb.length()-1);
		out.println(sb);
	}

	static PrintWriter out;
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out,true);
		}
		String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}

	public static boolean isPrime(int n) {
		if(n<2) return false;
		for(int i=2;i<=(int)Math.sqrt(n);i++) {
			if(n%i==0) return false;
		}
		return true;
	}

	public static void print(int a[],int l,int r){
		int i;
		for(i=l;i<=r;i++)
			out.print(a[i]+" ");
		out.println();
	}

	public static long fastexpo(long x, long y, long p){
		long res=1;
		while(y > 0){
			if((y & 1)==1)
				res= ((res%p)*(x%p))%p;
			y= y >> 1;			
			x = ((x%p)*(x%p))%p;
		}
		return res;
	}

	public static boolean[] sieve (int n) {
		boolean primes[]=new boolean[n+1];
		Arrays.fill(primes,true);
		primes[0]=primes[1]=false;
		for(int i=2;i*i<=n;i++){
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		}
		return primes;
	}

	public static long gcd(long a,long b){
        return (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue();
    }

    public static void merge(long a[],int l,int m,int r){
        int n1,n2,i,j,k;
        n1=m-l+1;
        n2=r-m;

        long L[]=new long[n1];
        long R[]=new long[n2];

        for(i=0;i<n1;i++)
            L[i]=a[l+i];
        for(j=0;j<n2;j++)
            R[j]=a[m+1+j];

        i=0;j=0;

        k=l;
        while(i<n1&&j<n2){
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            }
            k++;
        }

        while(i<n1){
            a[k]=L[i];
            i++;
            k++;
        }
        while(j<n2){
            a[k]=R[j];
            j++;
            k++;
        }
    }
    public static void sort(long a[],int l,int r){
        int m;
        if(l<r){
            m=(l+r)/2;
            sort(a,l,m);
            sort(a,m+1,r);
            merge(a,l,m,r);
        }
    }
}
 import java.util.*; util.* java import java.io.*; io.* java import java.math.*; math.* java public class Main{

	public static void main(String args[]){
		FastReader sc = new FastReader();
		StringBuilder sb=new StringBuilder();
		int t,i,n,x;
		t=1;
		while(t-->0){
            x=sc.nextInt();
            n=sc.nextInt();
            int a[]=new int[n];
            HashSet<Integer> set=new HashSet<>();
            for(i=0;i<n;i++){
                a[i]=sc.nextInt();
                set.add(a[i]);
            }
            int temp=x;
            int min=Integer.MAX_VALUE;
            int num=x;
            while(true){
                int val=x-temp;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp--;
            }
            temp=x;
            while(true){
                int val=temp-x;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp++;
            }
            sb.append(num).append('\n');
		}
		sb.deleteCharAt(sb.length()-1);
		out.println(sb);
	}

	static PrintWriter out;
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out,true);
		}
		String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}

	public static boolean isPrime(int n) {
		if(n<2) return false;
		for(int i=2;i<=(int)Math.sqrt(n);i++) {
			if(n%i==0) return false;
		}
		return true;
	}

	public static void print(int a[],int l,int r){
		int i;
		for(i=l;i<=r;i++)
			out.print(a[i]+" ");
		out.println();
	}

	public static long fastexpo(long x, long y, long p){
		long res=1;
		while(y > 0){
			if((y & 1)==1)
				res= ((res%p)*(x%p))%p;
			y= y >> 1;			
			x = ((x%p)*(x%p))%p;
		}
		return res;
	}

	public static boolean[] sieve (int n) {
		boolean primes[]=new boolean[n+1];
		Arrays.fill(primes,true);
		primes[0]=primes[1]=false;
		for(int i=2;i*i<=n;i++){
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		}
		return primes;
	}

	public static long gcd(long a,long b){
        return (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue();
    }

    public static void merge(long a[],int l,int m,int r){
        int n1,n2,i,j,k;
        n1=m-l+1;
        n2=r-m;

        long L[]=new long[n1];
        long R[]=new long[n2];

        for(i=0;i<n1;i++)
            L[i]=a[l+i];
        for(j=0;j<n2;j++)
            R[j]=a[m+1+j];

        i=0;j=0;

        k=l;
        while(i<n1&&j<n2){
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            }
            k++;
        }

        while(i<n1){
            a[k]=L[i];
            i++;
            k++;
        }
        while(j<n2){
            a[k]=R[j];
            j++;
            k++;
        }
    }
    public static void sort(long a[],int l,int r){
        int m;
        if(l<r){
            m=(l+r)/2;
            sort(a,l,m);
            sort(a,m+1,r);
            merge(a,l,m,r);
        }
    }
} Main static PrintWriter out; out public static void main(String args[]){
		FastReader sc = new FastReader();
		StringBuilder sb=new StringBuilder();
		int t,i,n,x;
		t=1;
		while(t-->0){
            x=sc.nextInt();
            n=sc.nextInt();
            int a[]=new int[n];
            HashSet<Integer> set=new HashSet<>();
            for(i=0;i<n;i++){
                a[i]=sc.nextInt();
                set.add(a[i]);
            }
            int temp=x;
            int min=Integer.MAX_VALUE;
            int num=x;
            while(true){
                int val=x-temp;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp--;
            }
            temp=x;
            while(true){
                int val=temp-x;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp++;
            }
            sb.append(num).append('\n');
		}
		sb.deleteCharAt(sb.length()-1);
		out.println(sb);
	} main {
		FastReader sc = new FastReader();
		StringBuilder sb=new StringBuilder();
		int t,i,n,x;
		t=1;
		while(t-->0){
            x=sc.nextInt();
            n=sc.nextInt();
            int a[]=new int[n];
            HashSet<Integer> set=new HashSet<>();
            for(i=0;i<n;i++){
                a[i]=sc.nextInt();
                set.add(a[i]);
            }
            int temp=x;
            int min=Integer.MAX_VALUE;
            int num=x;
            while(true){
                int val=x-temp;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp--;
            }
            temp=x;
            while(true){
                int val=temp-x;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp++;
            }
            sb.append(num).append('\n');
		}
		sb.deleteCharAt(sb.length()-1);
		out.println(sb);
	} FastReader sc = new FastReader(); sc new FastReader() StringBuilder sb=new StringBuilder(); sb new StringBuilder() int t t i i n n x; x t=1 t 1 while(t-->0){
            x=sc.nextInt();
            n=sc.nextInt();
            int a[]=new int[n];
            HashSet<Integer> set=new HashSet<>();
            for(i=0;i<n;i++){
                a[i]=sc.nextInt();
                set.add(a[i]);
            }
            int temp=x;
            int min=Integer.MAX_VALUE;
            int num=x;
            while(true){
                int val=x-temp;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp--;
            }
            temp=x;
            while(true){
                int val=temp-x;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp++;
            }
            sb.append(num).append('\n');
		} t-->0 t-- t 0 {
            x=sc.nextInt();
            n=sc.nextInt();
            int a[]=new int[n];
            HashSet<Integer> set=new HashSet<>();
            for(i=0;i<n;i++){
                a[i]=sc.nextInt();
                set.add(a[i]);
            }
            int temp=x;
            int min=Integer.MAX_VALUE;
            int num=x;
            while(true){
                int val=x-temp;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp--;
            }
            temp=x;
            while(true){
                int val=temp-x;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp++;
            }
            sb.append(num).append('\n');
		} x=sc.nextInt() x sc.nextInt() sc.nextInt sc n=sc.nextInt() n sc.nextInt() sc.nextInt sc int a[]=new int[n]; a new int[n] n HashSet<Integer> set=new HashSet<>(); set new HashSet<>() for(i=0;i<n;i++){
                a[i]=sc.nextInt();
                set.add(a[i]);
            } i=0; i=0 i 0 i<n i n i++ i++ i {
                a[i]=sc.nextInt();
                set.add(a[i]);
            } {
                a[i]=sc.nextInt();
                set.add(a[i]);
            } a[i]=sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc set.add(a[i]) set.add set a[i] a i int temp=x; temp x int min=Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE int num=x; num x while(true){
                int val=x-temp;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp--;
            } true {
                int val=x-temp;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp--;
            } int val=x-temp; val x-temp x temp if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                } !set.contains(temp)&&val<min !set.contains(temp) set.contains(temp) set.contains set temp val<min val min {
                    min=val;
                    num=temp;
                } min=val min val num=temp num temp if(val>min)
                    break; val>min val min break; temp-- temp temp=x temp x while(true){
                int val=temp-x;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp++;
            } true {
                int val=temp-x;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp++;
            } int val=temp-x; val temp-x temp x if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                } !set.contains(temp)&&val<min !set.contains(temp) set.contains(temp) set.contains set temp val<min val min {
                    min=val;
                    num=temp;
                } min=val min val num=temp num temp if(val>min)
                    break; val>min val min break; temp++ temp sb.append(num).append('\n') sb.append(num).append sb.append(num) sb.append sb num '\n' sb.deleteCharAt(sb.length()-1) sb.deleteCharAt sb sb.length()-1 sb.length() sb.length sb 1 out.println(sb) out.println out sb String args[] args public static boolean isPrime(int n) {
		if(n<2) return false;
		for(int i=2;i<=(int)Math.sqrt(n);i++) {
			if(n%i==0) return false;
		}
		return true;
	} isPrime {
		if(n<2) return false;
		for(int i=2;i<=(int)Math.sqrt(n);i++) {
			if(n%i==0) return false;
		}
		return true;
	} if(n<2) return false; n<2 n 2 return false; false for(int i=2;i<=(int)Math.sqrt(n);i++) {
			if(n%i==0) return false;
		} int i=2; int i=2; i 2 i<=(int)Math.sqrt(n) i (int)Math.sqrt(n) Math.sqrt Math n i++ i++ i {
			if(n%i==0) return false;
		} {
			if(n%i==0) return false;
		} if(n%i==0) return false; n%i==0 n%i n i 0 return false; false return true; true int n n public static void print(int a[],int l,int r){
		int i;
		for(i=l;i<=r;i++)
			out.print(a[i]+" ");
		out.println();
	} print {
		int i;
		for(i=l;i<=r;i++)
			out.print(a[i]+" ");
		out.println();
	} int i; i for(i=l;i<=r;i++)
			out.print(a[i]+" "); i=l; i=l i l i<=r i r i++ i++ i out.print(a[i]+" "); out.print(a[i]+" ") out.print out a[i]+" " a[i] a i " " out.println() out.println out int a[] a int l l int r r public static long fastexpo(long x, long y, long p){
		long res=1;
		while(y > 0){
			if((y & 1)==1)
				res= ((res%p)*(x%p))%p;
			y= y >> 1;			
			x = ((x%p)*(x%p))%p;
		}
		return res;
	} fastexpo {
		long res=1;
		while(y > 0){
			if((y & 1)==1)
				res= ((res%p)*(x%p))%p;
			y= y >> 1;			
			x = ((x%p)*(x%p))%p;
		}
		return res;
	} long res=1; res 1 while(y > 0){
			if((y & 1)==1)
				res= ((res%p)*(x%p))%p;
			y= y >> 1;			
			x = ((x%p)*(x%p))%p;
		} y > 0 y 0 {
			if((y & 1)==1)
				res= ((res%p)*(x%p))%p;
			y= y >> 1;			
			x = ((x%p)*(x%p))%p;
		} if((y & 1)==1)
				res= ((res%p)*(x%p))%p; (y & 1)==1 (y & 1) y 1 1 res= ((res%p)*(x%p))%p res ((res%p)*(x%p))%p ((res%p)*(x%p)) (res%p) res p (x%p) x p p y= y >> 1 y y >> 1 y 1 x = ((x%p)*(x%p))%p x ((x%p)*(x%p))%p ((x%p)*(x%p)) (x%p) x p (x%p) x p p return res; res long x x long y y long p p public static boolean[] sieve (int n) {
		boolean primes[]=new boolean[n+1];
		Arrays.fill(primes,true);
		primes[0]=primes[1]=false;
		for(int i=2;i*i<=n;i++){
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		}
		return primes;
	} sieve {
		boolean primes[]=new boolean[n+1];
		Arrays.fill(primes,true);
		primes[0]=primes[1]=false;
		for(int i=2;i*i<=n;i++){
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		}
		return primes;
	} boolean primes[]=new boolean[n+1]; primes new boolean[n+1] n+1 n 1 Arrays.fill(primes,true) Arrays.fill Arrays primes true primes[0]=primes[1]=false primes[0] primes 0 primes[1]=false primes[1] primes 1 false for(int i=2;i*i<=n;i++){
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		} int i=2; int i=2; i 2 i*i<=n i*i i i n i++ i++ i {
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		} {
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		} if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			} primes[i] primes i {
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			} for(int j=i*i;j<=n;j+=i)
					primes[j]=false; int j=i*i; int j=i*i; j i*i i i j<=n j n j+=i j+=i j i primes[j]=false; primes[j]=false primes[j] primes j false return primes; primes int n n public static long gcd(long a,long b){
        return (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue();
    } gcd {
        return (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue();
    } return (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue(); (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue() (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))) BigInteger.valueOf(a).gcd BigInteger.valueOf(a) BigInteger.valueOf BigInteger a BigInteger.valueOf(b) BigInteger.valueOf BigInteger b long a a long b b public static void merge(long a[],int l,int m,int r){
        int n1,n2,i,j,k;
        n1=m-l+1;
        n2=r-m;

        long L[]=new long[n1];
        long R[]=new long[n2];

        for(i=0;i<n1;i++)
            L[i]=a[l+i];
        for(j=0;j<n2;j++)
            R[j]=a[m+1+j];

        i=0;j=0;

        k=l;
        while(i<n1&&j<n2){
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            }
            k++;
        }

        while(i<n1){
            a[k]=L[i];
            i++;
            k++;
        }
        while(j<n2){
            a[k]=R[j];
            j++;
            k++;
        }
    } merge {
        int n1,n2,i,j,k;
        n1=m-l+1;
        n2=r-m;

        long L[]=new long[n1];
        long R[]=new long[n2];

        for(i=0;i<n1;i++)
            L[i]=a[l+i];
        for(j=0;j<n2;j++)
            R[j]=a[m+1+j];

        i=0;j=0;

        k=l;
        while(i<n1&&j<n2){
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            }
            k++;
        }

        while(i<n1){
            a[k]=L[i];
            i++;
            k++;
        }
        while(j<n2){
            a[k]=R[j];
            j++;
            k++;
        }
    } int n1 n1 n2 n2 i i j j k; k n1=m-l+1 n1 m-l+1 m-l m l 1 n2=r-m n2 r-m r m long L[]=new long[n1]; L new long[n1] n1 long R[]=new long[n2]; R new long[n2] n2 for(i=0;i<n1;i++)
            L[i]=a[l+i]; i=0; i=0 i 0 i<n1 i n1 i++ i++ i L[i]=a[l+i]; L[i]=a[l+i] L[i] L i a[l+i] a l+i l i for(j=0;j<n2;j++)
            R[j]=a[m+1+j]; j=0; j=0 j 0 j<n2 j n2 j++ j++ j R[j]=a[m+1+j]; R[j]=a[m+1+j] R[j] R j a[m+1+j] a m+1+j m+1+j m 1 j i=0 i 0 j=0 j 0 k=l k l while(i<n1&&j<n2){
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            }
            k++;
        } i<n1&&j<n2 i<n1 i n1 j<n2 j n2 {
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            }
            k++;
        } if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            } L[i]<=R[j] L[i] L i R[j] R j {
                a[k]=L[i];
                i++;
            } a[k]=L[i] a[k] a k L[i] L i i++ i {
                a[k]=R[j];
                j++;
            } a[k]=R[j] a[k] a k R[j] R j j++ j k++ k while(i<n1){
            a[k]=L[i];
            i++;
            k++;
        } i<n1 i n1 {
            a[k]=L[i];
            i++;
            k++;
        } a[k]=L[i] a[k] a k L[i] L i i++ i k++ k while(j<n2){
            a[k]=R[j];
            j++;
            k++;
        } j<n2 j n2 {
            a[k]=R[j];
            j++;
            k++;
        } a[k]=R[j] a[k] a k R[j] R j j++ j k++ k long a[] a int l l int m m int r r public static void sort(long a[],int l,int r){
        int m;
        if(l<r){
            m=(l+r)/2;
            sort(a,l,m);
            sort(a,m+1,r);
            merge(a,l,m,r);
        }
    } sort {
        int m;
        if(l<r){
            m=(l+r)/2;
            sort(a,l,m);
            sort(a,m+1,r);
            merge(a,l,m,r);
        }
    } int m; m if(l<r){
            m=(l+r)/2;
            sort(a,l,m);
            sort(a,m+1,r);
            merge(a,l,m,r);
        } l<r l r {
            m=(l+r)/2;
            sort(a,l,m);
            sort(a,m+1,r);
            merge(a,l,m,r);
        } m=(l+r)/2 m (l+r)/2 (l+r) l r 2 sort(a,l,m) sort a l m sort(a,m+1,r) sort a m+1 m 1 r merge(a,l,m,r) merge a l m r long a[] a int l l int r r static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out,true);
		}
		String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	} FastReader BufferedReader br; br StringTokenizer st; st public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out,true);
		} FastReader {
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out,true);
		} br=new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) out=new PrintWriter(System.out,true) out new PrintWriter(System.out,true) String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		} next {
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		} while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			} st==null || !st.hasMoreElements() st==null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			} try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				} catch (IOException e){
					e.printStackTrace();
				} IOException e {
					e.printStackTrace();
				} e.printStackTrace() e.printStackTrace e {
					st= new StringTokenizer(br.readLine());
				} st= new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt(){
			return Integer.parseInt(next());
		} nextInt {
			return Integer.parseInt(next());
		} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong(){
			return Long.parseLong(next());
		} nextLong {
			return Long.parseLong(next());
		} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble(){
			return Double.parseDouble(next());
		} nextDouble {
			return Double.parseDouble(next());
		} return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		} nextLine {
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		} String str = ""; str "" try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			} catch(IOException e){
				e.printStackTrace();
			} IOException e {
				e.printStackTrace();
			} e.printStackTrace() e.printStackTrace e {
				str=br.readLine();
			} str=br.readLine() str br.readLine() br.readLine br return str; str public class Main{

	public static void main(String args[]){
		FastReader sc = new FastReader();
		StringBuilder sb=new StringBuilder();
		int t,i,n,x;
		t=1;
		while(t-->0){
            x=sc.nextInt();
            n=sc.nextInt();
            int a[]=new int[n];
            HashSet<Integer> set=new HashSet<>();
            for(i=0;i<n;i++){
                a[i]=sc.nextInt();
                set.add(a[i]);
            }
            int temp=x;
            int min=Integer.MAX_VALUE;
            int num=x;
            while(true){
                int val=x-temp;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp--;
            }
            temp=x;
            while(true){
                int val=temp-x;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp++;
            }
            sb.append(num).append('\n');
		}
		sb.deleteCharAt(sb.length()-1);
		out.println(sb);
	}

	static PrintWriter out;
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out,true);
		}
		String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}

	public static boolean isPrime(int n) {
		if(n<2) return false;
		for(int i=2;i<=(int)Math.sqrt(n);i++) {
			if(n%i==0) return false;
		}
		return true;
	}

	public static void print(int a[],int l,int r){
		int i;
		for(i=l;i<=r;i++)
			out.print(a[i]+" ");
		out.println();
	}

	public static long fastexpo(long x, long y, long p){
		long res=1;
		while(y > 0){
			if((y & 1)==1)
				res= ((res%p)*(x%p))%p;
			y= y >> 1;			
			x = ((x%p)*(x%p))%p;
		}
		return res;
	}

	public static boolean[] sieve (int n) {
		boolean primes[]=new boolean[n+1];
		Arrays.fill(primes,true);
		primes[0]=primes[1]=false;
		for(int i=2;i*i<=n;i++){
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		}
		return primes;
	}

	public static long gcd(long a,long b){
        return (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue();
    }

    public static void merge(long a[],int l,int m,int r){
        int n1,n2,i,j,k;
        n1=m-l+1;
        n2=r-m;

        long L[]=new long[n1];
        long R[]=new long[n2];

        for(i=0;i<n1;i++)
            L[i]=a[l+i];
        for(j=0;j<n2;j++)
            R[j]=a[m+1+j];

        i=0;j=0;

        k=l;
        while(i<n1&&j<n2){
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            }
            k++;
        }

        while(i<n1){
            a[k]=L[i];
            i++;
            k++;
        }
        while(j<n2){
            a[k]=R[j];
            j++;
            k++;
        }
    }
    public static void sort(long a[],int l,int r){
        int m;
        if(l<r){
            m=(l+r)/2;
            sort(a,l,m);
            sort(a,m+1,r);
            merge(a,l,m,r);
        }
    }
} public class Main{

	public static void main(String args[]){
		FastReader sc = new FastReader();
		StringBuilder sb=new StringBuilder();
		int t,i,n,x;
		t=1;
		while(t-->0){
            x=sc.nextInt();
            n=sc.nextInt();
            int a[]=new int[n];
            HashSet<Integer> set=new HashSet<>();
            for(i=0;i<n;i++){
                a[i]=sc.nextInt();
                set.add(a[i]);
            }
            int temp=x;
            int min=Integer.MAX_VALUE;
            int num=x;
            while(true){
                int val=x-temp;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp--;
            }
            temp=x;
            while(true){
                int val=temp-x;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp++;
            }
            sb.append(num).append('\n');
		}
		sb.deleteCharAt(sb.length()-1);
		out.println(sb);
	}

	static PrintWriter out;
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out,true);
		}
		String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}

	public static boolean isPrime(int n) {
		if(n<2) return false;
		for(int i=2;i<=(int)Math.sqrt(n);i++) {
			if(n%i==0) return false;
		}
		return true;
	}

	public static void print(int a[],int l,int r){
		int i;
		for(i=l;i<=r;i++)
			out.print(a[i]+" ");
		out.println();
	}

	public static long fastexpo(long x, long y, long p){
		long res=1;
		while(y > 0){
			if((y & 1)==1)
				res= ((res%p)*(x%p))%p;
			y= y >> 1;			
			x = ((x%p)*(x%p))%p;
		}
		return res;
	}

	public static boolean[] sieve (int n) {
		boolean primes[]=new boolean[n+1];
		Arrays.fill(primes,true);
		primes[0]=primes[1]=false;
		for(int i=2;i*i<=n;i++){
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		}
		return primes;
	}

	public static long gcd(long a,long b){
        return (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue();
    }

    public static void merge(long a[],int l,int m,int r){
        int n1,n2,i,j,k;
        n1=m-l+1;
        n2=r-m;

        long L[]=new long[n1];
        long R[]=new long[n2];

        for(i=0;i<n1;i++)
            L[i]=a[l+i];
        for(j=0;j<n2;j++)
            R[j]=a[m+1+j];

        i=0;j=0;

        k=l;
        while(i<n1&&j<n2){
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            }
            k++;
        }

        while(i<n1){
            a[k]=L[i];
            i++;
            k++;
        }
        while(j<n2){
            a[k]=R[j];
            j++;
            k++;
        }
    }
    public static void sort(long a[],int l,int r){
        int m;
        if(l<r){
            m=(l+r)/2;
            sort(a,l,m);
            sort(a,m+1,r);
            merge(a,l,m,r);
        }
    }
} Main
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{

	public static void main(String args[]){
		FastReader sc = new FastReader();
		StringBuilder sb=new StringBuilder();
		int t,i,n,x;
		t=1;
		while(t-->0){
            x=sc.nextInt();
            n=sc.nextInt();
            int a[]=new int[n];
            HashSet<Integer> set=new HashSet<>();
            for(i=0;i<n;i++){
                a[i]=sc.nextInt();
                set.add(a[i]);
            }
            int temp=x;
            int min=Integer.MAX_VALUE;
            int num=x;
            while(true){
                int val=x-temp;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp--;
            }
            temp=x;
            while(true){
                int val=temp-x;
                if(!set.contains(temp)&&val<min){
                    min=val;
                    num=temp;
                }
                if(val>min)
                    break;
                temp++;
            }
            sb.append(num).append('\n');
		}
		sb.deleteCharAt(sb.length()-1);
		out.println(sb);
	}

	static PrintWriter out;
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out,true);
		}
		String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}

	public static boolean isPrime(int n) {
		if(n<2) return false;
		for(int i=2;i<=(int)Math.sqrt(n);i++) {
			if(n%i==0) return false;
		}
		return true;
	}

	public static void print(int a[],int l,int r){
		int i;
		for(i=l;i<=r;i++)
			out.print(a[i]+" ");
		out.println();
	}

	public static long fastexpo(long x, long y, long p){
		long res=1;
		while(y > 0){
			if((y & 1)==1)
				res= ((res%p)*(x%p))%p;
			y= y >> 1;			
			x = ((x%p)*(x%p))%p;
		}
		return res;
	}

	public static boolean[] sieve (int n) {
		boolean primes[]=new boolean[n+1];
		Arrays.fill(primes,true);
		primes[0]=primes[1]=false;
		for(int i=2;i*i<=n;i++){
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		}
		return primes;
	}

	public static long gcd(long a,long b){
        return (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue();
    }

    public static void merge(long a[],int l,int m,int r){
        int n1,n2,i,j,k;
        n1=m-l+1;
        n2=r-m;

        long L[]=new long[n1];
        long R[]=new long[n2];

        for(i=0;i<n1;i++)
            L[i]=a[l+i];
        for(j=0;j<n2;j++)
            R[j]=a[m+1+j];

        i=0;j=0;

        k=l;
        while(i<n1&&j<n2){
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            }
            k++;
        }

        while(i<n1){
            a[k]=L[i];
            i++;
            k++;
        }
        while(j<n2){
            a[k]=R[j];
            j++;
            k++;
        }
    }
    public static void sort(long a[],int l,int r){
        int m;
        if(l<r){
            m=(l+r)/2;
            sort(a,l,m);
            sort(a,m+1,r);
            merge(a,l,m,r);
        }
    }
}

