import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.math.BigDecimal;

public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);

        int X=sc.nextInt();
        int N=sc.nextInt();

        int[] p=new int[N+10];

        int[] up=new int[200];
        int[] dw=new int[200];

        Arrays.fill(up, 0);
        Arrays.fill(dw, 0);

        int i=0;
        dw[0]=1;

        for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            int sa=p[i]-X;

            if(sa>=0){
                up[sa]=1;
                //System.out.println("plus");
            }else{
                sa=sa*(-1);
                dw[sa]=1;
                //System.out.println("minus");
            }
            //System.out.println(dw[1]);
        }

        int hit=0;

        for(i=0;i<100;i++){
            if(dw[i]==0){
                hit=-i;
                //System.out.println(hit);
                break;
            }else if(up[i]==0){
                hit=i;
                //System.out.println(hit);
                break;
            }else if(i==X){
                //System.out.println("a"+"0");
                break;
            }
        }

        int ans=X+hit;

        //if(i!=X){
            System.out.println(ans);
        //}

        //END
    }
}


 import java.io.*; io.* java import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util import java.util.ArrayList; ArrayList java.util import java.math.BigDecimal; BigDecimal java.math public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);

        int X=sc.nextInt();
        int N=sc.nextInt();

        int[] p=new int[N+10];

        int[] up=new int[200];
        int[] dw=new int[200];

        Arrays.fill(up, 0);
        Arrays.fill(dw, 0);

        int i=0;
        dw[0]=1;

        for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            int sa=p[i]-X;

            if(sa>=0){
                up[sa]=1;
                //System.out.println("plus");
            }else{
                sa=sa*(-1);
                dw[sa]=1;
                //System.out.println("minus");
            }
            //System.out.println(dw[1]);
        }

        int hit=0;

        for(i=0;i<100;i++){
            if(dw[i]==0){
                hit=-i;
                //System.out.println(hit);
                break;
            }else if(up[i]==0){
                hit=i;
                //System.out.println(hit);
                break;
            }else if(i==X){
                //System.out.println("a"+"0");
                break;
            }
        }

        int ans=X+hit;

        //if(i!=X){
            System.out.println(ans);
        //}

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

        Scanner sc=new Scanner(System.in);

        int X=sc.nextInt();
        int N=sc.nextInt();

        int[] p=new int[N+10];

        int[] up=new int[200];
        int[] dw=new int[200];

        Arrays.fill(up, 0);
        Arrays.fill(dw, 0);

        int i=0;
        dw[0]=1;

        for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            int sa=p[i]-X;

            if(sa>=0){
                up[sa]=1;
                //System.out.println("plus");
            }else{
                sa=sa*(-1);
                dw[sa]=1;
                //System.out.println("minus");
            }
            //System.out.println(dw[1]);
        }

        int hit=0;

        for(i=0;i<100;i++){
            if(dw[i]==0){
                hit=-i;
                //System.out.println(hit);
                break;
            }else if(up[i]==0){
                hit=i;
                //System.out.println(hit);
                break;
            }else if(i==X){
                //System.out.println("a"+"0");
                break;
            }
        }

        int ans=X+hit;

        //if(i!=X){
            System.out.println(ans);
        //}

        //END
    } main {
        //START

        Scanner sc=new Scanner(System.in);

        int X=sc.nextInt();
        int N=sc.nextInt();

        int[] p=new int[N+10];

        int[] up=new int[200];
        int[] dw=new int[200];

        Arrays.fill(up, 0);
        Arrays.fill(dw, 0);

        int i=0;
        dw[0]=1;

        for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            int sa=p[i]-X;

            if(sa>=0){
                up[sa]=1;
                //System.out.println("plus");
            }else{
                sa=sa*(-1);
                dw[sa]=1;
                //System.out.println("minus");
            }
            //System.out.println(dw[1]);
        }

        int hit=0;

        for(i=0;i<100;i++){
            if(dw[i]==0){
                hit=-i;
                //System.out.println(hit);
                break;
            }else if(up[i]==0){
                hit=i;
                //System.out.println(hit);
                break;
            }else if(i==X){
                //System.out.println("a"+"0");
                break;
            }
        }

        int ans=X+hit;

        //if(i!=X){
            System.out.println(ans);
        //}

        //END
    } 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+10]; p new int[N+10] N+10 N 10 int[] up=new int[200]; up new int[200] 200 int[] dw=new int[200]; dw new int[200] 200 Arrays.fill(up, 0) Arrays.fill Arrays up 0 Arrays.fill(dw, 0) Arrays.fill Arrays dw 0 int i=0; i 0 dw[0]=1 dw[0] dw 0 1 for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            int sa=p[i]-X;

            if(sa>=0){
                up[sa]=1;
                //System.out.println("plus");
            }else{
                sa=sa*(-1);
                dw[sa]=1;
                //System.out.println("minus");
            }
            //System.out.println(dw[1]);
        } i=0; i=0 i 0 i<N i N i++ i++ i {
            p[i]=sc.nextInt();
            int sa=p[i]-X;

            if(sa>=0){
                up[sa]=1;
                //System.out.println("plus");
            }else{
                sa=sa*(-1);
                dw[sa]=1;
                //System.out.println("minus");
            }
            //System.out.println(dw[1]);
        } {
            p[i]=sc.nextInt();
            int sa=p[i]-X;

            if(sa>=0){
                up[sa]=1;
                //System.out.println("plus");
            }else{
                sa=sa*(-1);
                dw[sa]=1;
                //System.out.println("minus");
            }
            //System.out.println(dw[1]);
        } p[i]=sc.nextInt() p[i] p i sc.nextInt() sc.nextInt sc int sa=p[i]-X; sa p[i]-X p[i] p i X if(sa>=0){
                up[sa]=1;
                //System.out.println("plus");
            }else{
                sa=sa*(-1);
                dw[sa]=1;
                //System.out.println("minus");
            } sa>=0 sa 0 {
                up[sa]=1;
                //System.out.println("plus");
            } up[sa]=1 up[sa] up sa 1 {
                sa=sa*(-1);
                dw[sa]=1;
                //System.out.println("minus");
            } sa=sa*(-1) sa sa*(-1) sa (-1) 1 dw[sa]=1 dw[sa] dw sa 1 int hit=0; hit 0 for(i=0;i<100;i++){
            if(dw[i]==0){
                hit=-i;
                //System.out.println(hit);
                break;
            }else if(up[i]==0){
                hit=i;
                //System.out.println(hit);
                break;
            }else if(i==X){
                //System.out.println("a"+"0");
                break;
            }
        } i=0; i=0 i 0 i<100 i 100 i++ i++ i {
            if(dw[i]==0){
                hit=-i;
                //System.out.println(hit);
                break;
            }else if(up[i]==0){
                hit=i;
                //System.out.println(hit);
                break;
            }else if(i==X){
                //System.out.println("a"+"0");
                break;
            }
        } {
            if(dw[i]==0){
                hit=-i;
                //System.out.println(hit);
                break;
            }else if(up[i]==0){
                hit=i;
                //System.out.println(hit);
                break;
            }else if(i==X){
                //System.out.println("a"+"0");
                break;
            }
        } if(dw[i]==0){
                hit=-i;
                //System.out.println(hit);
                break;
            }else if(up[i]==0){
                hit=i;
                //System.out.println(hit);
                break;
            }else if(i==X){
                //System.out.println("a"+"0");
                break;
            } dw[i]==0 dw[i] dw i 0 {
                hit=-i;
                //System.out.println(hit);
                break;
            } hit=-i hit -i i break; if(up[i]==0){
                hit=i;
                //System.out.println(hit);
                break;
            }else if(i==X){
                //System.out.println("a"+"0");
                break;
            } up[i]==0 up[i] up i 0 {
                hit=i;
                //System.out.println(hit);
                break;
            } hit=i hit i break; if(i==X){
                //System.out.println("a"+"0");
                break;
            } i==X i X {
                //System.out.println("a"+"0");
                break;
            } break; int ans=X+hit; ans X+hit X hit System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);

        int X=sc.nextInt();
        int N=sc.nextInt();

        int[] p=new int[N+10];

        int[] up=new int[200];
        int[] dw=new int[200];

        Arrays.fill(up, 0);
        Arrays.fill(dw, 0);

        int i=0;
        dw[0]=1;

        for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            int sa=p[i]-X;

            if(sa>=0){
                up[sa]=1;
                //System.out.println("plus");
            }else{
                sa=sa*(-1);
                dw[sa]=1;
                //System.out.println("minus");
            }
            //System.out.println(dw[1]);
        }

        int hit=0;

        for(i=0;i<100;i++){
            if(dw[i]==0){
                hit=-i;
                //System.out.println(hit);
                break;
            }else if(up[i]==0){
                hit=i;
                //System.out.println(hit);
                break;
            }else if(i==X){
                //System.out.println("a"+"0");
                break;
            }
        }

        int ans=X+hit;

        //if(i!=X){
            System.out.println(ans);
        //}

        //END
    }
} public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);

        int X=sc.nextInt();
        int N=sc.nextInt();

        int[] p=new int[N+10];

        int[] up=new int[200];
        int[] dw=new int[200];

        Arrays.fill(up, 0);
        Arrays.fill(dw, 0);

        int i=0;
        dw[0]=1;

        for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            int sa=p[i]-X;

            if(sa>=0){
                up[sa]=1;
                //System.out.println("plus");
            }else{
                sa=sa*(-1);
                dw[sa]=1;
                //System.out.println("minus");
            }
            //System.out.println(dw[1]);
        }

        int hit=0;

        for(i=0;i<100;i++){
            if(dw[i]==0){
                hit=-i;
                //System.out.println(hit);
                break;
            }else if(up[i]==0){
                hit=i;
                //System.out.println(hit);
                break;
            }else if(i==X){
                //System.out.println("a"+"0");
                break;
            }
        }

        int ans=X+hit;

        //if(i!=X){
            System.out.println(ans);
        //}

        //END
    }
} Main
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.math.BigDecimal;

public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);

        int X=sc.nextInt();
        int N=sc.nextInt();

        int[] p=new int[N+10];

        int[] up=new int[200];
        int[] dw=new int[200];

        Arrays.fill(up, 0);
        Arrays.fill(dw, 0);

        int i=0;
        dw[0]=1;

        for(i=0;i<N;i++){
            p[i]=sc.nextInt();
            int sa=p[i]-X;

            if(sa>=0){
                up[sa]=1;
                //System.out.println("plus");
            }else{
                sa=sa*(-1);
                dw[sa]=1;
                //System.out.println("minus");
            }
            //System.out.println(dw[1]);
        }

        int hit=0;

        for(i=0;i<100;i++){
            if(dw[i]==0){
                hit=-i;
                //System.out.println(hit);
                break;
            }else if(up[i]==0){
                hit=i;
                //System.out.println(hit);
                break;
            }else if(i==X){
                //System.out.println("a"+"0");
                break;
            }
        }

        int ans=X+hit;

        //if(i!=X){
            System.out.println(ans);
        //}

        //END
    }
}



