import java.util.*;
public class Main{
  public static void main(String args[]){
      int i,x,n;
      Scanner scn =new Scanner(System.in);
      x=scn.nextInt();
      n=scn.nextInt();
      int[] a= new int[n];
      HashMap<Integer,Boolean> map = new HashMap<>();
      for(i=0;i<n;i++){
         a[i]=scn.nextInt();
         map.put(a[i],true);
       }
      int check = x;
      int diff =0;

       while(true){
          if(!map.containsKey(check-diff)){
             System.out.println(check-diff);
             break;
           }
           
          else if(!map.containsKey(check+diff)){
             System.out.println(check+diff);
             break;
           }
           
           else diff++;
        }
   }
}

 import java.util.*; util.* java public class Main{
  public static void main(String args[]){
      int i,x,n;
      Scanner scn =new Scanner(System.in);
      x=scn.nextInt();
      n=scn.nextInt();
      int[] a= new int[n];
      HashMap<Integer,Boolean> map = new HashMap<>();
      for(i=0;i<n;i++){
         a[i]=scn.nextInt();
         map.put(a[i],true);
       }
      int check = x;
      int diff =0;

       while(true){
          if(!map.containsKey(check-diff)){
             System.out.println(check-diff);
             break;
           }
           
          else if(!map.containsKey(check+diff)){
             System.out.println(check+diff);
             break;
           }
           
           else diff++;
        }
   }
} Main public static void main(String args[]){
      int i,x,n;
      Scanner scn =new Scanner(System.in);
      x=scn.nextInt();
      n=scn.nextInt();
      int[] a= new int[n];
      HashMap<Integer,Boolean> map = new HashMap<>();
      for(i=0;i<n;i++){
         a[i]=scn.nextInt();
         map.put(a[i],true);
       }
      int check = x;
      int diff =0;

       while(true){
          if(!map.containsKey(check-diff)){
             System.out.println(check-diff);
             break;
           }
           
          else if(!map.containsKey(check+diff)){
             System.out.println(check+diff);
             break;
           }
           
           else diff++;
        }
   } main {
      int i,x,n;
      Scanner scn =new Scanner(System.in);
      x=scn.nextInt();
      n=scn.nextInt();
      int[] a= new int[n];
      HashMap<Integer,Boolean> map = new HashMap<>();
      for(i=0;i<n;i++){
         a[i]=scn.nextInt();
         map.put(a[i],true);
       }
      int check = x;
      int diff =0;

       while(true){
          if(!map.containsKey(check-diff)){
             System.out.println(check-diff);
             break;
           }
           
          else if(!map.containsKey(check+diff)){
             System.out.println(check+diff);
             break;
           }
           
           else diff++;
        }
   } int i i x x n; n Scanner scn =new Scanner(System.in); scn new Scanner(System.in) x=scn.nextInt() x scn.nextInt() scn.nextInt scn n=scn.nextInt() n scn.nextInt() scn.nextInt scn int[] a= new int[n]; a new int[n] n HashMap<Integer,Boolean> map = new HashMap<>(); map new HashMap<>() for(i=0;i<n;i++){
         a[i]=scn.nextInt();
         map.put(a[i],true);
       } i=0; i=0 i 0 i<n i n i++ i++ i {
         a[i]=scn.nextInt();
         map.put(a[i],true);
       } {
         a[i]=scn.nextInt();
         map.put(a[i],true);
       } a[i]=scn.nextInt() a[i] a i scn.nextInt() scn.nextInt scn map.put(a[i],true) map.put map a[i] a i true int check = x; check x int diff =0; diff 0 while(true){
          if(!map.containsKey(check-diff)){
             System.out.println(check-diff);
             break;
           }
           
          else if(!map.containsKey(check+diff)){
             System.out.println(check+diff);
             break;
           }
           
           else diff++;
        } true {
          if(!map.containsKey(check-diff)){
             System.out.println(check-diff);
             break;
           }
           
          else if(!map.containsKey(check+diff)){
             System.out.println(check+diff);
             break;
           }
           
           else diff++;
        } if(!map.containsKey(check-diff)){
             System.out.println(check-diff);
             break;
           }
           
          else if(!map.containsKey(check+diff)){
             System.out.println(check+diff);
             break;
           }
           
           else diff++; !map.containsKey(check-diff) map.containsKey(check-diff) map.containsKey map check-diff check diff {
             System.out.println(check-diff);
             break;
           } System.out.println(check-diff) System.out.println System.out System System.out check-diff check diff break; if(!map.containsKey(check+diff)){
             System.out.println(check+diff);
             break;
           }
           
           else diff++; !map.containsKey(check+diff) map.containsKey(check+diff) map.containsKey map check+diff check diff {
             System.out.println(check+diff);
             break;
           } System.out.println(check+diff) System.out.println System.out System System.out check+diff check diff break; diff++ diff String args[] args public class Main{
  public static void main(String args[]){
      int i,x,n;
      Scanner scn =new Scanner(System.in);
      x=scn.nextInt();
      n=scn.nextInt();
      int[] a= new int[n];
      HashMap<Integer,Boolean> map = new HashMap<>();
      for(i=0;i<n;i++){
         a[i]=scn.nextInt();
         map.put(a[i],true);
       }
      int check = x;
      int diff =0;

       while(true){
          if(!map.containsKey(check-diff)){
             System.out.println(check-diff);
             break;
           }
           
          else if(!map.containsKey(check+diff)){
             System.out.println(check+diff);
             break;
           }
           
           else diff++;
        }
   }
} public class Main{
  public static void main(String args[]){
      int i,x,n;
      Scanner scn =new Scanner(System.in);
      x=scn.nextInt();
      n=scn.nextInt();
      int[] a= new int[n];
      HashMap<Integer,Boolean> map = new HashMap<>();
      for(i=0;i<n;i++){
         a[i]=scn.nextInt();
         map.put(a[i],true);
       }
      int check = x;
      int diff =0;

       while(true){
          if(!map.containsKey(check-diff)){
             System.out.println(check-diff);
             break;
           }
           
          else if(!map.containsKey(check+diff)){
             System.out.println(check+diff);
             break;
           }
           
           else diff++;
        }
   }
} Main
import java.util.*;
public class Main{
  public static void main(String args[]){
      int i,x,n;
      Scanner scn =new Scanner(System.in);
      x=scn.nextInt();
      n=scn.nextInt();
      int[] a= new int[n];
      HashMap<Integer,Boolean> map = new HashMap<>();
      for(i=0;i<n;i++){
         a[i]=scn.nextInt();
         map.put(a[i],true);
       }
      int check = x;
      int diff =0;

       while(true){
          if(!map.containsKey(check-diff)){
             System.out.println(check-diff);
             break;
           }
           
          else if(!map.containsKey(check+diff)){
             System.out.println(check+diff);
             break;
           }
           
           else diff++;
        }
   }
}


