import java.util.*;
public class Main{

     public static void main(String []args){
        
        Scanner sc=new Scanner(System.in);
        List<Integer> li=new ArrayList<Integer>();
        int x=sc.nextInt();
        int y=sc.nextInt();
        for(int i=0;i<y;i++)
        li.add(sc.nextInt());
        for(int i=0;i<=x;i++)
        {
            int sub=x-i;
            int add=x+i;
            if(!(li.contains(sub) )){
                
              System.out.println(sub);
              System.exit(0);}
            if(!( li.contains(add))){
               System.out.println(add);
               System.exit(0);}
        }
       System.out.println("-1");  
     }
} import java.util.*; util.* java public class Main{

     public static void main(String []args){
        
        Scanner sc=new Scanner(System.in);
        List<Integer> li=new ArrayList<Integer>();
        int x=sc.nextInt();
        int y=sc.nextInt();
        for(int i=0;i<y;i++)
        li.add(sc.nextInt());
        for(int i=0;i<=x;i++)
        {
            int sub=x-i;
            int add=x+i;
            if(!(li.contains(sub) )){
                
              System.out.println(sub);
              System.exit(0);}
            if(!( li.contains(add))){
               System.out.println(add);
               System.exit(0);}
        }
       System.out.println("-1");  
     }
} Main public static void main(String []args){
        
        Scanner sc=new Scanner(System.in);
        List<Integer> li=new ArrayList<Integer>();
        int x=sc.nextInt();
        int y=sc.nextInt();
        for(int i=0;i<y;i++)
        li.add(sc.nextInt());
        for(int i=0;i<=x;i++)
        {
            int sub=x-i;
            int add=x+i;
            if(!(li.contains(sub) )){
                
              System.out.println(sub);
              System.exit(0);}
            if(!( li.contains(add))){
               System.out.println(add);
               System.exit(0);}
        }
       System.out.println("-1");  
     } main {
        
        Scanner sc=new Scanner(System.in);
        List<Integer> li=new ArrayList<Integer>();
        int x=sc.nextInt();
        int y=sc.nextInt();
        for(int i=0;i<y;i++)
        li.add(sc.nextInt());
        for(int i=0;i<=x;i++)
        {
            int sub=x-i;
            int add=x+i;
            if(!(li.contains(sub) )){
                
              System.out.println(sub);
              System.exit(0);}
            if(!( li.contains(add))){
               System.out.println(add);
               System.exit(0);}
        }
       System.out.println("-1");  
     } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) List<Integer> li=new ArrayList<Integer>(); li new ArrayList<Integer>() int x=sc.nextInt(); x sc.nextInt() sc.nextInt sc int y=sc.nextInt(); y sc.nextInt() sc.nextInt sc for(int i=0;i<y;i++)
        li.add(sc.nextInt()); int i=0; int i=0; i 0 i<y i y i++ i++ i li.add(sc.nextInt()); li.add(sc.nextInt()) li.add li sc.nextInt() sc.nextInt sc for(int i=0;i<=x;i++)
        {
            int sub=x-i;
            int add=x+i;
            if(!(li.contains(sub) )){
                
              System.out.println(sub);
              System.exit(0);}
            if(!( li.contains(add))){
               System.out.println(add);
               System.exit(0);}
        } int i=0; int i=0; i 0 i<=x i x i++ i++ i {
            int sub=x-i;
            int add=x+i;
            if(!(li.contains(sub) )){
                
              System.out.println(sub);
              System.exit(0);}
            if(!( li.contains(add))){
               System.out.println(add);
               System.exit(0);}
        } {
            int sub=x-i;
            int add=x+i;
            if(!(li.contains(sub) )){
                
              System.out.println(sub);
              System.exit(0);}
            if(!( li.contains(add))){
               System.out.println(add);
               System.exit(0);}
        } int sub=x-i; sub x-i x i int add=x+i; add x+i x i if(!(li.contains(sub) )){
                
              System.out.println(sub);
              System.exit(0);} !(li.contains(sub) ) (li.contains(sub) ) li.contains li sub {
                
              System.out.println(sub);
              System.exit(0);} System.out.println(sub) System.out.println System.out System System.out sub System.exit(0) System.exit System 0 if(!( li.contains(add))){
               System.out.println(add);
               System.exit(0);} !( li.contains(add)) ( li.contains(add)) li.contains li add {
               System.out.println(add);
               System.exit(0);} System.out.println(add) System.out.println System.out System System.out add System.exit(0) System.exit System 0 System.out.println("-1") System.out.println System.out System System.out "-1" String []args args public class Main{

     public static void main(String []args){
        
        Scanner sc=new Scanner(System.in);
        List<Integer> li=new ArrayList<Integer>();
        int x=sc.nextInt();
        int y=sc.nextInt();
        for(int i=0;i<y;i++)
        li.add(sc.nextInt());
        for(int i=0;i<=x;i++)
        {
            int sub=x-i;
            int add=x+i;
            if(!(li.contains(sub) )){
                
              System.out.println(sub);
              System.exit(0);}
            if(!( li.contains(add))){
               System.out.println(add);
               System.exit(0);}
        }
       System.out.println("-1");  
     }
} public class Main{

     public static void main(String []args){
        
        Scanner sc=new Scanner(System.in);
        List<Integer> li=new ArrayList<Integer>();
        int x=sc.nextInt();
        int y=sc.nextInt();
        for(int i=0;i<y;i++)
        li.add(sc.nextInt());
        for(int i=0;i<=x;i++)
        {
            int sub=x-i;
            int add=x+i;
            if(!(li.contains(sub) )){
                
              System.out.println(sub);
              System.exit(0);}
            if(!( li.contains(add))){
               System.out.println(add);
               System.exit(0);}
        }
       System.out.println("-1");  
     }
} Main
import java.util.*;
public class Main{

     public static void main(String []args){
        
        Scanner sc=new Scanner(System.in);
        List<Integer> li=new ArrayList<Integer>();
        int x=sc.nextInt();
        int y=sc.nextInt();
        for(int i=0;i<y;i++)
        li.add(sc.nextInt());
        for(int i=0;i<=x;i++)
        {
            int sub=x-i;
            int add=x+i;
            if(!(li.contains(sub) )){
                
              System.out.println(sub);
              System.exit(0);}
            if(!( li.contains(add))){
               System.out.println(add);
               System.exit(0);}
        }
       System.out.println("-1");  
     }
}