import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        String[] a = input.split(" ");
        int x = Integer.parseInt(a[0]);
        int n = Integer.parseInt(a[1]);
        input = stdIn.nextLine();
        int z = x;
        int w = x;
        int c = 0;
        int d = 0;
        String[] b = input.split(" ");

        if(b.length == n){
            while(true){
                for(int i = 0 ; i < b.length ; i++){
                    if(w == Integer.parseInt(b[i])){
                        c += 1;
                        w -= 1;
                    }
                    if(z == Integer.parseInt(b[i])){
                        c += 1;
                        z += 1;
                    }
                }
                if(c == 0){

                    break;
                }
                c = 0;
            }
            if(x - w > z - x){
                System.out.println(z);
            }else{
                System.out.println(w);
            }
        }else if(n == 0){
            System.out.println(x);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        String[] a = input.split(" ");
        int x = Integer.parseInt(a[0]);
        int n = Integer.parseInt(a[1]);
        input = stdIn.nextLine();
        int z = x;
        int w = x;
        int c = 0;
        int d = 0;
        String[] b = input.split(" ");

        if(b.length == n){
            while(true){
                for(int i = 0 ; i < b.length ; i++){
                    if(w == Integer.parseInt(b[i])){
                        c += 1;
                        w -= 1;
                    }
                    if(z == Integer.parseInt(b[i])){
                        c += 1;
                        z += 1;
                    }
                }
                if(c == 0){

                    break;
                }
                c = 0;
            }
            if(x - w > z - x){
                System.out.println(z);
            }else{
                System.out.println(w);
            }
        }else if(n == 0){
            System.out.println(x);
        }
    }
} Main public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        String[] a = input.split(" ");
        int x = Integer.parseInt(a[0]);
        int n = Integer.parseInt(a[1]);
        input = stdIn.nextLine();
        int z = x;
        int w = x;
        int c = 0;
        int d = 0;
        String[] b = input.split(" ");

        if(b.length == n){
            while(true){
                for(int i = 0 ; i < b.length ; i++){
                    if(w == Integer.parseInt(b[i])){
                        c += 1;
                        w -= 1;
                    }
                    if(z == Integer.parseInt(b[i])){
                        c += 1;
                        z += 1;
                    }
                }
                if(c == 0){

                    break;
                }
                c = 0;
            }
            if(x - w > z - x){
                System.out.println(z);
            }else{
                System.out.println(w);
            }
        }else if(n == 0){
            System.out.println(x);
        }
    } main {
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        String[] a = input.split(" ");
        int x = Integer.parseInt(a[0]);
        int n = Integer.parseInt(a[1]);
        input = stdIn.nextLine();
        int z = x;
        int w = x;
        int c = 0;
        int d = 0;
        String[] b = input.split(" ");

        if(b.length == n){
            while(true){
                for(int i = 0 ; i < b.length ; i++){
                    if(w == Integer.parseInt(b[i])){
                        c += 1;
                        w -= 1;
                    }
                    if(z == Integer.parseInt(b[i])){
                        c += 1;
                        z += 1;
                    }
                }
                if(c == 0){

                    break;
                }
                c = 0;
            }
            if(x - w > z - x){
                System.out.println(z);
            }else{
                System.out.println(w);
            }
        }else if(n == 0){
            System.out.println(x);
        }
    } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) String input = stdIn.nextLine(); input stdIn.nextLine() stdIn.nextLine stdIn String[] a = input.split(" "); a input.split(" ") input.split input " " int x = Integer.parseInt(a[0]); x Integer.parseInt(a[0]) Integer.parseInt Integer a[0] a 0 int n = Integer.parseInt(a[1]); n Integer.parseInt(a[1]) Integer.parseInt Integer a[1] a 1 input = stdIn.nextLine() input stdIn.nextLine() stdIn.nextLine stdIn int z = x; z x int w = x; w x int c = 0; c 0 int d = 0; d 0 String[] b = input.split(" "); b input.split(" ") input.split input " " if(b.length == n){
            while(true){
                for(int i = 0 ; i < b.length ; i++){
                    if(w == Integer.parseInt(b[i])){
                        c += 1;
                        w -= 1;
                    }
                    if(z == Integer.parseInt(b[i])){
                        c += 1;
                        z += 1;
                    }
                }
                if(c == 0){

                    break;
                }
                c = 0;
            }
            if(x - w > z - x){
                System.out.println(z);
            }else{
                System.out.println(w);
            }
        }else if(n == 0){
            System.out.println(x);
        } b.length == n b.length b b.length n {
            while(true){
                for(int i = 0 ; i < b.length ; i++){
                    if(w == Integer.parseInt(b[i])){
                        c += 1;
                        w -= 1;
                    }
                    if(z == Integer.parseInt(b[i])){
                        c += 1;
                        z += 1;
                    }
                }
                if(c == 0){

                    break;
                }
                c = 0;
            }
            if(x - w > z - x){
                System.out.println(z);
            }else{
                System.out.println(w);
            }
        } while(true){
                for(int i = 0 ; i < b.length ; i++){
                    if(w == Integer.parseInt(b[i])){
                        c += 1;
                        w -= 1;
                    }
                    if(z == Integer.parseInt(b[i])){
                        c += 1;
                        z += 1;
                    }
                }
                if(c == 0){

                    break;
                }
                c = 0;
            } true {
                for(int i = 0 ; i < b.length ; i++){
                    if(w == Integer.parseInt(b[i])){
                        c += 1;
                        w -= 1;
                    }
                    if(z == Integer.parseInt(b[i])){
                        c += 1;
                        z += 1;
                    }
                }
                if(c == 0){

                    break;
                }
                c = 0;
            } for(int i = 0 ; i < b.length ; i++){
                    if(w == Integer.parseInt(b[i])){
                        c += 1;
                        w -= 1;
                    }
                    if(z == Integer.parseInt(b[i])){
                        c += 1;
                        z += 1;
                    }
                } int i = 0 ; int i = 0 ; i 0 i < b.length i b.length b b.length i++ i++ i {
                    if(w == Integer.parseInt(b[i])){
                        c += 1;
                        w -= 1;
                    }
                    if(z == Integer.parseInt(b[i])){
                        c += 1;
                        z += 1;
                    }
                } {
                    if(w == Integer.parseInt(b[i])){
                        c += 1;
                        w -= 1;
                    }
                    if(z == Integer.parseInt(b[i])){
                        c += 1;
                        z += 1;
                    }
                } if(w == Integer.parseInt(b[i])){
                        c += 1;
                        w -= 1;
                    } w == Integer.parseInt(b[i]) w Integer.parseInt(b[i]) Integer.parseInt Integer b[i] b i {
                        c += 1;
                        w -= 1;
                    } c += 1 c 1 w -= 1 w 1 if(z == Integer.parseInt(b[i])){
                        c += 1;
                        z += 1;
                    } z == Integer.parseInt(b[i]) z Integer.parseInt(b[i]) Integer.parseInt Integer b[i] b i {
                        c += 1;
                        z += 1;
                    } c += 1 c 1 z += 1 z 1 if(c == 0){

                    break;
                } c == 0 c 0 {

                    break;
                } break; c = 0 c 0 if(x - w > z - x){
                System.out.println(z);
            }else{
                System.out.println(w);
            } x - w > z - x x - w x w z - x z x {
                System.out.println(z);
            } System.out.println(z) System.out.println System.out System System.out z {
                System.out.println(w);
            } System.out.println(w) System.out.println System.out System System.out w if(n == 0){
            System.out.println(x);
        } n == 0 n 0 {
            System.out.println(x);
        } System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        String[] a = input.split(" ");
        int x = Integer.parseInt(a[0]);
        int n = Integer.parseInt(a[1]);
        input = stdIn.nextLine();
        int z = x;
        int w = x;
        int c = 0;
        int d = 0;
        String[] b = input.split(" ");

        if(b.length == n){
            while(true){
                for(int i = 0 ; i < b.length ; i++){
                    if(w == Integer.parseInt(b[i])){
                        c += 1;
                        w -= 1;
                    }
                    if(z == Integer.parseInt(b[i])){
                        c += 1;
                        z += 1;
                    }
                }
                if(c == 0){

                    break;
                }
                c = 0;
            }
            if(x - w > z - x){
                System.out.println(z);
            }else{
                System.out.println(w);
            }
        }else if(n == 0){
            System.out.println(x);
        }
    }
} public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        String[] a = input.split(" ");
        int x = Integer.parseInt(a[0]);
        int n = Integer.parseInt(a[1]);
        input = stdIn.nextLine();
        int z = x;
        int w = x;
        int c = 0;
        int d = 0;
        String[] b = input.split(" ");

        if(b.length == n){
            while(true){
                for(int i = 0 ; i < b.length ; i++){
                    if(w == Integer.parseInt(b[i])){
                        c += 1;
                        w -= 1;
                    }
                    if(z == Integer.parseInt(b[i])){
                        c += 1;
                        z += 1;
                    }
                }
                if(c == 0){

                    break;
                }
                c = 0;
            }
            if(x - w > z - x){
                System.out.println(z);
            }else{
                System.out.println(w);
            }
        }else if(n == 0){
            System.out.println(x);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        String[] a = input.split(" ");
        int x = Integer.parseInt(a[0]);
        int n = Integer.parseInt(a[1]);
        input = stdIn.nextLine();
        int z = x;
        int w = x;
        int c = 0;
        int d = 0;
        String[] b = input.split(" ");

        if(b.length == n){
            while(true){
                for(int i = 0 ; i < b.length ; i++){
                    if(w == Integer.parseInt(b[i])){
                        c += 1;
                        w -= 1;
                    }
                    if(z == Integer.parseInt(b[i])){
                        c += 1;
                        z += 1;
                    }
                }
                if(c == 0){

                    break;
                }
                c = 0;
            }
            if(x - w > z - x){
                System.out.println(z);
            }else{
                System.out.println(w);
            }
        }else if(n == 0){
            System.out.println(x);
        }
    }
}
