import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        int X = in.nextInt();   // 整数
        int N = in.nextInt();   // 長さ
        int p[] = new int[N];
        for(int i=0; i<N; i++)
            p[i] = in.nextInt();
        int tmp = 0;

        for(int i=0; tmp==0; i++){
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X-i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X-i);
                break;
            }
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X+i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X+i);
                break;
            }
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        int X = in.nextInt();   // 整数
        int N = in.nextInt();   // 長さ
        int p[] = new int[N];
        for(int i=0; i<N; i++)
            p[i] = in.nextInt();
        int tmp = 0;

        for(int i=0; tmp==0; i++){
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X-i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X-i);
                break;
            }
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X+i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X+i);
                break;
            }
        }
    }
} Main public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        int X = in.nextInt();   // 整数
        int N = in.nextInt();   // 長さ
        int p[] = new int[N];
        for(int i=0; i<N; i++)
            p[i] = in.nextInt();
        int tmp = 0;

        for(int i=0; tmp==0; i++){
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X-i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X-i);
                break;
            }
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X+i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X+i);
                break;
            }
        }
    } main {
        Scanner in = new Scanner(System.in);

        int X = in.nextInt();   // 整数
        int N = in.nextInt();   // 長さ
        int p[] = new int[N];
        for(int i=0; i<N; i++)
            p[i] = in.nextInt();
        int tmp = 0;

        for(int i=0; tmp==0; i++){
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X-i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X-i);
                break;
            }
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X+i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X+i);
                break;
            }
        }
    } 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 int p[] = new int[N]; p new int[N] N for(int i=0; i<N; i++)
            p[i] = in.nextInt(); int i=0; int i=0; i 0 i<N i N i++ i++ i p[i] = in.nextInt(); p[i] = in.nextInt() p[i] p i in.nextInt() in.nextInt in int tmp = 0; tmp 0 for(int i=0; tmp==0; i++){
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X-i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X-i);
                break;
            }
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X+i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X+i);
                break;
            }
        } int i=0; int i=0; i 0 tmp==0 tmp 0 i++ i++ i {
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X-i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X-i);
                break;
            }
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X+i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X+i);
                break;
            }
        } {
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X-i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X-i);
                break;
            }
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X+i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X+i);
                break;
            }
        } tmp = 1 tmp 1 for(int j=0; j<N; j++){
                if( X-i == p[j]){
                    tmp = 0;
                }
            } int j=0; int j=0; j 0 j<N j N j++ j++ j {
                if( X-i == p[j]){
                    tmp = 0;
                }
            } {
                if( X-i == p[j]){
                    tmp = 0;
                }
            } if( X-i == p[j]){
                    tmp = 0;
                } X-i == p[j] X-i X i p[j] p j {
                    tmp = 0;
                } tmp = 0 tmp 0 if(tmp == 1){
                System.out.println(X-i);
                break;
            } tmp == 1 tmp 1 {
                System.out.println(X-i);
                break;
            } System.out.println(X-i) System.out.println System.out System System.out X-i X i break; tmp = 1 tmp 1 for(int j=0; j<N; j++){
                if( X+i == p[j]){
                    tmp = 0;
                }
            } int j=0; int j=0; j 0 j<N j N j++ j++ j {
                if( X+i == p[j]){
                    tmp = 0;
                }
            } {
                if( X+i == p[j]){
                    tmp = 0;
                }
            } if( X+i == p[j]){
                    tmp = 0;
                } X+i == p[j] X+i X i p[j] p j {
                    tmp = 0;
                } tmp = 0 tmp 0 if(tmp == 1){
                System.out.println(X+i);
                break;
            } tmp == 1 tmp 1 {
                System.out.println(X+i);
                break;
            } System.out.println(X+i) System.out.println System.out System System.out X+i X i break; String[] args args public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        int X = in.nextInt();   // 整数
        int N = in.nextInt();   // 長さ
        int p[] = new int[N];
        for(int i=0; i<N; i++)
            p[i] = in.nextInt();
        int tmp = 0;

        for(int i=0; tmp==0; i++){
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X-i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X-i);
                break;
            }
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X+i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X+i);
                break;
            }
        }
    }
} public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        int X = in.nextInt();   // 整数
        int N = in.nextInt();   // 長さ
        int p[] = new int[N];
        for(int i=0; i<N; i++)
            p[i] = in.nextInt();
        int tmp = 0;

        for(int i=0; tmp==0; i++){
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X-i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X-i);
                break;
            }
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X+i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X+i);
                break;
            }
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        int X = in.nextInt();   // 整数
        int N = in.nextInt();   // 長さ
        int p[] = new int[N];
        for(int i=0; i<N; i++)
            p[i] = in.nextInt();
        int tmp = 0;

        for(int i=0; tmp==0; i++){
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X-i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X-i);
                break;
            }
            tmp = 1;
            for(int j=0; j<N; j++){
                if( X+i == p[j]){
                    tmp = 0;
                }
            }
            if(tmp == 1){
                System.out.println(X+i);
                break;
            }
        }
    }
}