import java.util.*;

public class Main{

public static void main(String[] args) {
Scanner scn=new Scanner (System.in);
int x=scn.nextInt();
int n=scn.nextInt();
int []arr=new int[n];
boolean team=false;
for(int i=0;i<n;i++){
    arr[i]=scn.nextInt();
    if(arr[i]==x){
        team=true;
    }
}
Arrays.sort(arr);
if(arr.length==0){
    System.out.println(x);
    return;
}
if( team==false){
    System.out.println(x);
    return;
}
int idx=0;
for(int i=0;i<arr.length;i++){
    if(arr[i]==x){
        idx=i;
    }
    
}

int p1=idx+1;
int p2=idx-1;
int val=1;
while(p1!=arr.length && p2!=-1){
    if(arr[p2]!=x-val){
      
        System.out.println(x-val);
        return;
    }
    if(arr[p1]!=x+val){
         
        System.out.println(x+val);
        return;
    }
    val++;
    p2--;
    p1++;
}
if(p1!=arr.length){

   System.out.println(x-val);
   return;
}
if(p2!=-1){
    
    if(arr[p2]==x-val){
         
        System.out.println(x+val);
        return;
    }
      
     System.out.println(x-val);
     return;
}
System.out.println(arr[0]-1);



 }
} import java.util.*; util.* java public class Main{

public static void main(String[] args) {
Scanner scn=new Scanner (System.in);
int x=scn.nextInt();
int n=scn.nextInt();
int []arr=new int[n];
boolean team=false;
for(int i=0;i<n;i++){
    arr[i]=scn.nextInt();
    if(arr[i]==x){
        team=true;
    }
}
Arrays.sort(arr);
if(arr.length==0){
    System.out.println(x);
    return;
}
if( team==false){
    System.out.println(x);
    return;
}
int idx=0;
for(int i=0;i<arr.length;i++){
    if(arr[i]==x){
        idx=i;
    }
    
}

int p1=idx+1;
int p2=idx-1;
int val=1;
while(p1!=arr.length && p2!=-1){
    if(arr[p2]!=x-val){
      
        System.out.println(x-val);
        return;
    }
    if(arr[p1]!=x+val){
         
        System.out.println(x+val);
        return;
    }
    val++;
    p2--;
    p1++;
}
if(p1!=arr.length){

   System.out.println(x-val);
   return;
}
if(p2!=-1){
    
    if(arr[p2]==x-val){
         
        System.out.println(x+val);
        return;
    }
      
     System.out.println(x-val);
     return;
}
System.out.println(arr[0]-1);



 }
} Main public static void main(String[] args) {
Scanner scn=new Scanner (System.in);
int x=scn.nextInt();
int n=scn.nextInt();
int []arr=new int[n];
boolean team=false;
for(int i=0;i<n;i++){
    arr[i]=scn.nextInt();
    if(arr[i]==x){
        team=true;
    }
}
Arrays.sort(arr);
if(arr.length==0){
    System.out.println(x);
    return;
}
if( team==false){
    System.out.println(x);
    return;
}
int idx=0;
for(int i=0;i<arr.length;i++){
    if(arr[i]==x){
        idx=i;
    }
    
}

int p1=idx+1;
int p2=idx-1;
int val=1;
while(p1!=arr.length && p2!=-1){
    if(arr[p2]!=x-val){
      
        System.out.println(x-val);
        return;
    }
    if(arr[p1]!=x+val){
         
        System.out.println(x+val);
        return;
    }
    val++;
    p2--;
    p1++;
}
if(p1!=arr.length){

   System.out.println(x-val);
   return;
}
if(p2!=-1){
    
    if(arr[p2]==x-val){
         
        System.out.println(x+val);
        return;
    }
      
     System.out.println(x-val);
     return;
}
System.out.println(arr[0]-1);



 } main {
Scanner scn=new Scanner (System.in);
int x=scn.nextInt();
int n=scn.nextInt();
int []arr=new int[n];
boolean team=false;
for(int i=0;i<n;i++){
    arr[i]=scn.nextInt();
    if(arr[i]==x){
        team=true;
    }
}
Arrays.sort(arr);
if(arr.length==0){
    System.out.println(x);
    return;
}
if( team==false){
    System.out.println(x);
    return;
}
int idx=0;
for(int i=0;i<arr.length;i++){
    if(arr[i]==x){
        idx=i;
    }
    
}

int p1=idx+1;
int p2=idx-1;
int val=1;
while(p1!=arr.length && p2!=-1){
    if(arr[p2]!=x-val){
      
        System.out.println(x-val);
        return;
    }
    if(arr[p1]!=x+val){
         
        System.out.println(x+val);
        return;
    }
    val++;
    p2--;
    p1++;
}
if(p1!=arr.length){

   System.out.println(x-val);
   return;
}
if(p2!=-1){
    
    if(arr[p2]==x-val){
         
        System.out.println(x+val);
        return;
    }
      
     System.out.println(x-val);
     return;
}
System.out.println(arr[0]-1);



 } Scanner scn=new Scanner (System.in); scn new Scanner (System.in) int x=scn.nextInt(); x scn.nextInt() scn.nextInt scn int n=scn.nextInt(); n scn.nextInt() scn.nextInt scn int []arr=new int[n]; arr new int[n] n boolean team=false; team false for(int i=0;i<n;i++){
    arr[i]=scn.nextInt();
    if(arr[i]==x){
        team=true;
    }
} int i=0; int i=0; i 0 i<n i n i++ i++ i {
    arr[i]=scn.nextInt();
    if(arr[i]==x){
        team=true;
    }
} {
    arr[i]=scn.nextInt();
    if(arr[i]==x){
        team=true;
    }
} arr[i]=scn.nextInt() arr[i] arr i scn.nextInt() scn.nextInt scn if(arr[i]==x){
        team=true;
    } arr[i]==x arr[i] arr i x {
        team=true;
    } team=true team true Arrays.sort(arr) Arrays.sort Arrays arr if(arr.length==0){
    System.out.println(x);
    return;
} arr.length==0 arr.length arr arr.length 0 {
    System.out.println(x);
    return;
} System.out.println(x) System.out.println System.out System System.out x return; if( team==false){
    System.out.println(x);
    return;
} team==false team false {
    System.out.println(x);
    return;
} System.out.println(x) System.out.println System.out System System.out x return; int idx=0; idx 0 for(int i=0;i<arr.length;i++){
    if(arr[i]==x){
        idx=i;
    }
    
} int i=0; int i=0; i 0 i<arr.length i arr.length arr arr.length i++ i++ i {
    if(arr[i]==x){
        idx=i;
    }
    
} {
    if(arr[i]==x){
        idx=i;
    }
    
} if(arr[i]==x){
        idx=i;
    } arr[i]==x arr[i] arr i x {
        idx=i;
    } idx=i idx i int p1=idx+1; p1 idx+1 idx 1 int p2=idx-1; p2 idx-1 idx 1 int val=1; val 1 while(p1!=arr.length && p2!=-1){
    if(arr[p2]!=x-val){
      
        System.out.println(x-val);
        return;
    }
    if(arr[p1]!=x+val){
         
        System.out.println(x+val);
        return;
    }
    val++;
    p2--;
    p1++;
} p1!=arr.length && p2!=-1 p1!=arr.length p1 arr.length arr arr.length p2!=-1 p2 -1 1 {
    if(arr[p2]!=x-val){
      
        System.out.println(x-val);
        return;
    }
    if(arr[p1]!=x+val){
         
        System.out.println(x+val);
        return;
    }
    val++;
    p2--;
    p1++;
} if(arr[p2]!=x-val){
      
        System.out.println(x-val);
        return;
    } arr[p2]!=x-val arr[p2] arr p2 x-val x val {
      
        System.out.println(x-val);
        return;
    } System.out.println(x-val) System.out.println System.out System System.out x-val x val return; if(arr[p1]!=x+val){
         
        System.out.println(x+val);
        return;
    } arr[p1]!=x+val arr[p1] arr p1 x+val x val {
         
        System.out.println(x+val);
        return;
    } System.out.println(x+val) System.out.println System.out System System.out x+val x val return; val++ val p2-- p2 p1++ p1 if(p1!=arr.length){

   System.out.println(x-val);
   return;
} p1!=arr.length p1 arr.length arr arr.length {

   System.out.println(x-val);
   return;
} System.out.println(x-val) System.out.println System.out System System.out x-val x val return; if(p2!=-1){
    
    if(arr[p2]==x-val){
         
        System.out.println(x+val);
        return;
    }
      
     System.out.println(x-val);
     return;
} p2!=-1 p2 -1 1 {
    
    if(arr[p2]==x-val){
         
        System.out.println(x+val);
        return;
    }
      
     System.out.println(x-val);
     return;
} if(arr[p2]==x-val){
         
        System.out.println(x+val);
        return;
    } arr[p2]==x-val arr[p2] arr p2 x-val x val {
         
        System.out.println(x+val);
        return;
    } System.out.println(x+val) System.out.println System.out System System.out x+val x val return; System.out.println(x-val) System.out.println System.out System System.out x-val x val return; System.out.println(arr[0]-1) System.out.println System.out System System.out arr[0]-1 arr[0] arr 0 1 String[] args args public class Main{

public static void main(String[] args) {
Scanner scn=new Scanner (System.in);
int x=scn.nextInt();
int n=scn.nextInt();
int []arr=new int[n];
boolean team=false;
for(int i=0;i<n;i++){
    arr[i]=scn.nextInt();
    if(arr[i]==x){
        team=true;
    }
}
Arrays.sort(arr);
if(arr.length==0){
    System.out.println(x);
    return;
}
if( team==false){
    System.out.println(x);
    return;
}
int idx=0;
for(int i=0;i<arr.length;i++){
    if(arr[i]==x){
        idx=i;
    }
    
}

int p1=idx+1;
int p2=idx-1;
int val=1;
while(p1!=arr.length && p2!=-1){
    if(arr[p2]!=x-val){
      
        System.out.println(x-val);
        return;
    }
    if(arr[p1]!=x+val){
         
        System.out.println(x+val);
        return;
    }
    val++;
    p2--;
    p1++;
}
if(p1!=arr.length){

   System.out.println(x-val);
   return;
}
if(p2!=-1){
    
    if(arr[p2]==x-val){
         
        System.out.println(x+val);
        return;
    }
      
     System.out.println(x-val);
     return;
}
System.out.println(arr[0]-1);



 }
} public class Main{

public static void main(String[] args) {
Scanner scn=new Scanner (System.in);
int x=scn.nextInt();
int n=scn.nextInt();
int []arr=new int[n];
boolean team=false;
for(int i=0;i<n;i++){
    arr[i]=scn.nextInt();
    if(arr[i]==x){
        team=true;
    }
}
Arrays.sort(arr);
if(arr.length==0){
    System.out.println(x);
    return;
}
if( team==false){
    System.out.println(x);
    return;
}
int idx=0;
for(int i=0;i<arr.length;i++){
    if(arr[i]==x){
        idx=i;
    }
    
}

int p1=idx+1;
int p2=idx-1;
int val=1;
while(p1!=arr.length && p2!=-1){
    if(arr[p2]!=x-val){
      
        System.out.println(x-val);
        return;
    }
    if(arr[p1]!=x+val){
         
        System.out.println(x+val);
        return;
    }
    val++;
    p2--;
    p1++;
}
if(p1!=arr.length){

   System.out.println(x-val);
   return;
}
if(p2!=-1){
    
    if(arr[p2]==x-val){
         
        System.out.println(x+val);
        return;
    }
      
     System.out.println(x-val);
     return;
}
System.out.println(arr[0]-1);



 }
} Main
import java.util.*;

public class Main{

public static void main(String[] args) {
Scanner scn=new Scanner (System.in);
int x=scn.nextInt();
int n=scn.nextInt();
int []arr=new int[n];
boolean team=false;
for(int i=0;i<n;i++){
    arr[i]=scn.nextInt();
    if(arr[i]==x){
        team=true;
    }
}
Arrays.sort(arr);
if(arr.length==0){
    System.out.println(x);
    return;
}
if( team==false){
    System.out.println(x);
    return;
}
int idx=0;
for(int i=0;i<arr.length;i++){
    if(arr[i]==x){
        idx=i;
    }
    
}

int p1=idx+1;
int p2=idx-1;
int val=1;
while(p1!=arr.length && p2!=-1){
    if(arr[p2]!=x-val){
      
        System.out.println(x-val);
        return;
    }
    if(arr[p1]!=x+val){
         
        System.out.println(x+val);
        return;
    }
    val++;
    p2--;
    p1++;
}
if(p1!=arr.length){

   System.out.println(x-val);
   return;
}
if(p2!=-1){
    
    if(arr[p2]==x-val){
         
        System.out.println(x+val);
        return;
    }
      
     System.out.println(x-val);
     return;
}
System.out.println(arr[0]-1);



 }
}