import java.util.*;

public class Main{
    public static void main(String[] args){

        Scanner scanner = new Scanner(System.in);

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

        int p[] = new int[N];
        for(int loop=0; loop<N; loop++) {
            p[loop] = scanner.nextInt();
        }

        int sol = X;
        int dis = 0;
        while(true) {

            int ans = sol - dis;

            boolean exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            ans = sol + dis;

            exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            dis++;
        }

        System.out.println( sol );

    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){

        Scanner scanner = new Scanner(System.in);

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

        int p[] = new int[N];
        for(int loop=0; loop<N; loop++) {
            p[loop] = scanner.nextInt();
        }

        int sol = X;
        int dis = 0;
        while(true) {

            int ans = sol - dis;

            boolean exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            ans = sol + dis;

            exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            dis++;
        }

        System.out.println( sol );

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

        Scanner scanner = new Scanner(System.in);

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

        int p[] = new int[N];
        for(int loop=0; loop<N; loop++) {
            p[loop] = scanner.nextInt();
        }

        int sol = X;
        int dis = 0;
        while(true) {

            int ans = sol - dis;

            boolean exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            ans = sol + dis;

            exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            dis++;
        }

        System.out.println( sol );

    } main {

        Scanner scanner = new Scanner(System.in);

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

        int p[] = new int[N];
        for(int loop=0; loop<N; loop++) {
            p[loop] = scanner.nextInt();
        }

        int sol = X;
        int dis = 0;
        while(true) {

            int ans = sol - dis;

            boolean exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            ans = sol + dis;

            exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            dis++;
        }

        System.out.println( sol );

    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int X = scanner.nextInt(); X scanner.nextInt() scanner.nextInt scanner int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int p[] = new int[N]; p new int[N] N for(int loop=0; loop<N; loop++) {
            p[loop] = scanner.nextInt();
        } int loop=0; int loop=0; loop 0 loop<N loop N loop++ loop++ loop {
            p[loop] = scanner.nextInt();
        } {
            p[loop] = scanner.nextInt();
        } p[loop] = scanner.nextInt() p[loop] p loop scanner.nextInt() scanner.nextInt scanner int sol = X; sol X int dis = 0; dis 0 while(true) {

            int ans = sol - dis;

            boolean exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            ans = sol + dis;

            exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            dis++;
        } true {

            int ans = sol - dis;

            boolean exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            ans = sol + dis;

            exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            dis++;
        } int ans = sol - dis; ans sol - dis sol dis boolean exist = false; exist false for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            } int loop=0; int loop=0; loop 0 loop<N loop N loop++ loop++ loop {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            } {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            } if( ans == p[loop] ){
                    exist = true;
                    break;
                } ans == p[loop] ans p[loop] p loop {
                    exist = true;
                    break;
                } exist = true exist true break; if( exist == false ) {
                sol = ans;
                break;
            } exist == false exist false {
                sol = ans;
                break;
            } sol = ans sol ans break; ans = sol + dis ans sol + dis sol dis exist = false exist false for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            } int loop=0; int loop=0; loop 0 loop<N loop N loop++ loop++ loop {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            } {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            } if( ans == p[loop] ){
                    exist = true;
                    break;
                } ans == p[loop] ans p[loop] p loop {
                    exist = true;
                    break;
                } exist = true exist true break; if( exist == false ) {
                sol = ans;
                break;
            } exist == false exist false {
                sol = ans;
                break;
            } sol = ans sol ans break; dis++ dis System.out.println( sol ) System.out.println System.out System System.out sol String[] args args public class Main{
    public static void main(String[] args){

        Scanner scanner = new Scanner(System.in);

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

        int p[] = new int[N];
        for(int loop=0; loop<N; loop++) {
            p[loop] = scanner.nextInt();
        }

        int sol = X;
        int dis = 0;
        while(true) {

            int ans = sol - dis;

            boolean exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            ans = sol + dis;

            exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            dis++;
        }

        System.out.println( sol );

    }
} public class Main{
    public static void main(String[] args){

        Scanner scanner = new Scanner(System.in);

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

        int p[] = new int[N];
        for(int loop=0; loop<N; loop++) {
            p[loop] = scanner.nextInt();
        }

        int sol = X;
        int dis = 0;
        while(true) {

            int ans = sol - dis;

            boolean exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            ans = sol + dis;

            exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            dis++;
        }

        System.out.println( sol );

    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args){

        Scanner scanner = new Scanner(System.in);

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

        int p[] = new int[N];
        for(int loop=0; loop<N; loop++) {
            p[loop] = scanner.nextInt();
        }

        int sol = X;
        int dis = 0;
        while(true) {

            int ans = sol - dis;

            boolean exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            ans = sol + dis;

            exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            dis++;
        }

        System.out.println( sol );

    }
}