import java.util.*;

class Main
{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int n = input.nextInt();
        ArrayList<Integer> p = new ArrayList();
        for (int i = 0; i < n; i++) {
            p.add(input.nextInt());
        }
        int left=x-1, right=x+1;

        Collections.sort(p);
        if(!p.contains(x)){
            System.out.print(x);
        }else{
            for(int i=0; i<n; i++){
                if(p.contains(left)){
                    left--;
                }
                if(p.contains(right)){
                    right++;
                }
                if(!p.contains(left)&&!p.contains(right)){
                    if(Math.abs(x-left)>Math.abs(x-right)){
                        System.out.print(right);
                        
                        return;
                    }else{
                        System.out.print(left);
                        return;
                    }
                }
            }
        }
    }
} import java.util.*; util.* java class Main
{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int n = input.nextInt();
        ArrayList<Integer> p = new ArrayList();
        for (int i = 0; i < n; i++) {
            p.add(input.nextInt());
        }
        int left=x-1, right=x+1;

        Collections.sort(p);
        if(!p.contains(x)){
            System.out.print(x);
        }else{
            for(int i=0; i<n; i++){
                if(p.contains(left)){
                    left--;
                }
                if(p.contains(right)){
                    right++;
                }
                if(!p.contains(left)&&!p.contains(right)){
                    if(Math.abs(x-left)>Math.abs(x-right)){
                        System.out.print(right);
                        
                        return;
                    }else{
                        System.out.print(left);
                        return;
                    }
                }
            }
        }
    }
} Main public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int n = input.nextInt();
        ArrayList<Integer> p = new ArrayList();
        for (int i = 0; i < n; i++) {
            p.add(input.nextInt());
        }
        int left=x-1, right=x+1;

        Collections.sort(p);
        if(!p.contains(x)){
            System.out.print(x);
        }else{
            for(int i=0; i<n; i++){
                if(p.contains(left)){
                    left--;
                }
                if(p.contains(right)){
                    right++;
                }
                if(!p.contains(left)&&!p.contains(right)){
                    if(Math.abs(x-left)>Math.abs(x-right)){
                        System.out.print(right);
                        
                        return;
                    }else{
                        System.out.print(left);
                        return;
                    }
                }
            }
        }
    } main {
        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int n = input.nextInt();
        ArrayList<Integer> p = new ArrayList();
        for (int i = 0; i < n; i++) {
            p.add(input.nextInt());
        }
        int left=x-1, right=x+1;

        Collections.sort(p);
        if(!p.contains(x)){
            System.out.print(x);
        }else{
            for(int i=0; i<n; i++){
                if(p.contains(left)){
                    left--;
                }
                if(p.contains(right)){
                    right++;
                }
                if(!p.contains(left)&&!p.contains(right)){
                    if(Math.abs(x-left)>Math.abs(x-right)){
                        System.out.print(right);
                        
                        return;
                    }else{
                        System.out.print(left);
                        return;
                    }
                }
            }
        }
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) int x = input.nextInt(); x input.nextInt() input.nextInt input int n = input.nextInt(); n input.nextInt() input.nextInt input ArrayList<Integer> p = new ArrayList(); p new ArrayList() for (int i = 0; i < n; i++) {
            p.add(input.nextInt());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            p.add(input.nextInt());
        } {
            p.add(input.nextInt());
        } p.add(input.nextInt()) p.add p input.nextInt() input.nextInt input int left=x-1 left x-1 x 1 right=x+1; right x+1 x 1 Collections.sort(p) Collections.sort Collections p if(!p.contains(x)){
            System.out.print(x);
        }else{
            for(int i=0; i<n; i++){
                if(p.contains(left)){
                    left--;
                }
                if(p.contains(right)){
                    right++;
                }
                if(!p.contains(left)&&!p.contains(right)){
                    if(Math.abs(x-left)>Math.abs(x-right)){
                        System.out.print(right);
                        
                        return;
                    }else{
                        System.out.print(left);
                        return;
                    }
                }
            }
        } !p.contains(x) p.contains(x) p.contains p x {
            System.out.print(x);
        } System.out.print(x) System.out.print System.out System System.out x {
            for(int i=0; i<n; i++){
                if(p.contains(left)){
                    left--;
                }
                if(p.contains(right)){
                    right++;
                }
                if(!p.contains(left)&&!p.contains(right)){
                    if(Math.abs(x-left)>Math.abs(x-right)){
                        System.out.print(right);
                        
                        return;
                    }else{
                        System.out.print(left);
                        return;
                    }
                }
            }
        } for(int i=0; i<n; i++){
                if(p.contains(left)){
                    left--;
                }
                if(p.contains(right)){
                    right++;
                }
                if(!p.contains(left)&&!p.contains(right)){
                    if(Math.abs(x-left)>Math.abs(x-right)){
                        System.out.print(right);
                        
                        return;
                    }else{
                        System.out.print(left);
                        return;
                    }
                }
            } int i=0; int i=0; i 0 i<n i n i++ i++ i {
                if(p.contains(left)){
                    left--;
                }
                if(p.contains(right)){
                    right++;
                }
                if(!p.contains(left)&&!p.contains(right)){
                    if(Math.abs(x-left)>Math.abs(x-right)){
                        System.out.print(right);
                        
                        return;
                    }else{
                        System.out.print(left);
                        return;
                    }
                }
            } {
                if(p.contains(left)){
                    left--;
                }
                if(p.contains(right)){
                    right++;
                }
                if(!p.contains(left)&&!p.contains(right)){
                    if(Math.abs(x-left)>Math.abs(x-right)){
                        System.out.print(right);
                        
                        return;
                    }else{
                        System.out.print(left);
                        return;
                    }
                }
            } if(p.contains(left)){
                    left--;
                } p.contains(left) p.contains p left {
                    left--;
                } left-- left if(p.contains(right)){
                    right++;
                } p.contains(right) p.contains p right {
                    right++;
                } right++ right if(!p.contains(left)&&!p.contains(right)){
                    if(Math.abs(x-left)>Math.abs(x-right)){
                        System.out.print(right);
                        
                        return;
                    }else{
                        System.out.print(left);
                        return;
                    }
                } !p.contains(left)&&!p.contains(right) !p.contains(left) p.contains(left) p.contains p left !p.contains(right) p.contains(right) p.contains p right {
                    if(Math.abs(x-left)>Math.abs(x-right)){
                        System.out.print(right);
                        
                        return;
                    }else{
                        System.out.print(left);
                        return;
                    }
                } if(Math.abs(x-left)>Math.abs(x-right)){
                        System.out.print(right);
                        
                        return;
                    }else{
                        System.out.print(left);
                        return;
                    } Math.abs(x-left)>Math.abs(x-right) Math.abs(x-left) Math.abs Math x-left x left Math.abs(x-right) Math.abs Math x-right x right {
                        System.out.print(right);
                        
                        return;
                    } System.out.print(right) System.out.print System.out System System.out right return; {
                        System.out.print(left);
                        return;
                    } System.out.print(left) System.out.print System.out System System.out left return; String[] args args
import java.util.*;

class Main
{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int n = input.nextInt();
        ArrayList<Integer> p = new ArrayList();
        for (int i = 0; i < n; i++) {
            p.add(input.nextInt());
        }
        int left=x-1, right=x+1;

        Collections.sort(p);
        if(!p.contains(x)){
            System.out.print(x);
        }else{
            for(int i=0; i<n; i++){
                if(p.contains(left)){
                    left--;
                }
                if(p.contains(right)){
                    right++;
                }
                if(!p.contains(left)&&!p.contains(right)){
                    if(Math.abs(x-left)>Math.abs(x-right)){
                        System.out.print(right);
                        
                        return;
                    }else{
                        System.out.print(left);
                        return;
                    }
                }
            }
        }
    }
}