import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int N , X;
      int i = 0; 
      while (scan.hasNextLine()) {
      String an = scan.nextLine();
      list.add(an);
      }
      String List[] = list.get(0).split(" ",0);
      X = Integer.parseInt(List[0]);
      N = Integer.parseInt(List[1]);
  //    System.out.println(N);
      int num[] = new int[N];
      if(N != 0){
      String Atai[] = list.get(1).split(" ",0);
      while(i < N){
        num[i] = Integer.parseInt(Atai[i]);
        i++;
      }
              
      Arrays.sort(num);
      check(num,X,N);
      }else{
       System.out.println(X);
        }

        scan.close();
    }
  
  public static void check(int[] num,int x,int n){
   //System.out.println(num[0]);
    List<Integer> numList = new ArrayList<Integer>(num.length);
    for (int i = 0; i < num.length; i++) {
       numList.add(num[i]);
    }
    int s,l;
     s = x;
     l = x;
    while(true) {
      if(numList.contains(s)){
        s = s-1;
        if(numList.contains(l)){
          l = l + 1;
         }else{
          System.out.println(l);
          break;
        }
        }else{
       System.out.println(s);
//       System.out.println("ok");
       break;
      }
     
      }
    }
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.List; List java.util public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int N , X;
      int i = 0; 
      while (scan.hasNextLine()) {
      String an = scan.nextLine();
      list.add(an);
      }
      String List[] = list.get(0).split(" ",0);
      X = Integer.parseInt(List[0]);
      N = Integer.parseInt(List[1]);
  //    System.out.println(N);
      int num[] = new int[N];
      if(N != 0){
      String Atai[] = list.get(1).split(" ",0);
      while(i < N){
        num[i] = Integer.parseInt(Atai[i]);
        i++;
      }
              
      Arrays.sort(num);
      check(num,X,N);
      }else{
       System.out.println(X);
        }

        scan.close();
    }
  
  public static void check(int[] num,int x,int n){
   //System.out.println(num[0]);
    List<Integer> numList = new ArrayList<Integer>(num.length);
    for (int i = 0; i < num.length; i++) {
       numList.add(num[i]);
    }
    int s,l;
     s = x;
     l = x;
    while(true) {
      if(numList.contains(s)){
        s = s-1;
        if(numList.contains(l)){
          l = l + 1;
         }else{
          System.out.println(l);
          break;
        }
        }else{
       System.out.println(s);
//       System.out.println("ok");
       break;
      }
     
      }
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int N , X;
      int i = 0; 
      while (scan.hasNextLine()) {
      String an = scan.nextLine();
      list.add(an);
      }
      String List[] = list.get(0).split(" ",0);
      X = Integer.parseInt(List[0]);
      N = Integer.parseInt(List[1]);
  //    System.out.println(N);
      int num[] = new int[N];
      if(N != 0){
      String Atai[] = list.get(1).split(" ",0);
      while(i < N){
        num[i] = Integer.parseInt(Atai[i]);
        i++;
      }
              
      Arrays.sort(num);
      check(num,X,N);
      }else{
       System.out.println(X);
        }

        scan.close();
    } main {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int N , X;
      int i = 0; 
      while (scan.hasNextLine()) {
      String an = scan.nextLine();
      list.add(an);
      }
      String List[] = list.get(0).split(" ",0);
      X = Integer.parseInt(List[0]);
      N = Integer.parseInt(List[1]);
  //    System.out.println(N);
      int num[] = new int[N];
      if(N != 0){
      String Atai[] = list.get(1).split(" ",0);
      while(i < N){
        num[i] = Integer.parseInt(Atai[i]);
        i++;
      }
              
      Arrays.sort(num);
      check(num,X,N);
      }else{
       System.out.println(X);
        }

        scan.close();
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) ArrayList<String> list = new ArrayList<String>(); list new ArrayList<String>() int N N X; X int i = 0; i 0 while (scan.hasNextLine()) {
      String an = scan.nextLine();
      list.add(an);
      } scan.hasNextLine() scan.hasNextLine scan {
      String an = scan.nextLine();
      list.add(an);
      } String an = scan.nextLine(); an scan.nextLine() scan.nextLine scan list.add(an) list.add list an String List[] = list.get(0).split(" ",0); List list.get(0).split(" ",0) list.get(0).split list.get(0) list.get list 0 " " 0 X = Integer.parseInt(List[0]) X Integer.parseInt(List[0]) Integer.parseInt Integer List[0] List 0 N = Integer.parseInt(List[1]) N Integer.parseInt(List[1]) Integer.parseInt Integer List[1] List 1 int num[] = new int[N]; num new int[N] N if(N != 0){
      String Atai[] = list.get(1).split(" ",0);
      while(i < N){
        num[i] = Integer.parseInt(Atai[i]);
        i++;
      }
              
      Arrays.sort(num);
      check(num,X,N);
      }else{
       System.out.println(X);
        } N != 0 N 0 {
      String Atai[] = list.get(1).split(" ",0);
      while(i < N){
        num[i] = Integer.parseInt(Atai[i]);
        i++;
      }
              
      Arrays.sort(num);
      check(num,X,N);
      } String Atai[] = list.get(1).split(" ",0); Atai list.get(1).split(" ",0) list.get(1).split list.get(1) list.get list 1 " " 0 while(i < N){
        num[i] = Integer.parseInt(Atai[i]);
        i++;
      } i < N i N {
        num[i] = Integer.parseInt(Atai[i]);
        i++;
      } num[i] = Integer.parseInt(Atai[i]) num[i] num i Integer.parseInt(Atai[i]) Integer.parseInt Integer Atai[i] Atai i i++ i Arrays.sort(num) Arrays.sort Arrays num check(num,X,N) check num X N {
       System.out.println(X);
        } System.out.println(X) System.out.println System.out System System.out X scan.close() scan.close scan String[] args args public static void check(int[] num,int x,int n){
   //System.out.println(num[0]);
    List<Integer> numList = new ArrayList<Integer>(num.length);
    for (int i = 0; i < num.length; i++) {
       numList.add(num[i]);
    }
    int s,l;
     s = x;
     l = x;
    while(true) {
      if(numList.contains(s)){
        s = s-1;
        if(numList.contains(l)){
          l = l + 1;
         }else{
          System.out.println(l);
          break;
        }
        }else{
       System.out.println(s);
//       System.out.println("ok");
       break;
      }
     
      }
    } check {
   //System.out.println(num[0]);
    List<Integer> numList = new ArrayList<Integer>(num.length);
    for (int i = 0; i < num.length; i++) {
       numList.add(num[i]);
    }
    int s,l;
     s = x;
     l = x;
    while(true) {
      if(numList.contains(s)){
        s = s-1;
        if(numList.contains(l)){
          l = l + 1;
         }else{
          System.out.println(l);
          break;
        }
        }else{
       System.out.println(s);
//       System.out.println("ok");
       break;
      }
     
      }
    } List<Integer> numList = new ArrayList<Integer>(num.length); numList new ArrayList<Integer>(num.length) for (int i = 0; i < num.length; i++) {
       numList.add(num[i]);
    } int i = 0; int i = 0; i 0 i < num.length i num.length num num.length i++ i++ i {
       numList.add(num[i]);
    } {
       numList.add(num[i]);
    } numList.add(num[i]) numList.add numList num[i] num i int s s l; l s = x s x l = x l x while(true) {
      if(numList.contains(s)){
        s = s-1;
        if(numList.contains(l)){
          l = l + 1;
         }else{
          System.out.println(l);
          break;
        }
        }else{
       System.out.println(s);
//       System.out.println("ok");
       break;
      }
     
      } true {
      if(numList.contains(s)){
        s = s-1;
        if(numList.contains(l)){
          l = l + 1;
         }else{
          System.out.println(l);
          break;
        }
        }else{
       System.out.println(s);
//       System.out.println("ok");
       break;
      }
     
      } if(numList.contains(s)){
        s = s-1;
        if(numList.contains(l)){
          l = l + 1;
         }else{
          System.out.println(l);
          break;
        }
        }else{
       System.out.println(s);
//       System.out.println("ok");
       break;
      } numList.contains(s) numList.contains numList s {
        s = s-1;
        if(numList.contains(l)){
          l = l + 1;
         }else{
          System.out.println(l);
          break;
        }
        } s = s-1 s s-1 s 1 if(numList.contains(l)){
          l = l + 1;
         }else{
          System.out.println(l);
          break;
        } numList.contains(l) numList.contains numList l {
          l = l + 1;
         } l = l + 1 l l + 1 l 1 {
          System.out.println(l);
          break;
        } System.out.println(l) System.out.println System.out System System.out l break; {
       System.out.println(s);
//       System.out.println("ok");
       break;
      } System.out.println(s) System.out.println System.out System System.out s break; int[] num num int x x int n n public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int N , X;
      int i = 0; 
      while (scan.hasNextLine()) {
      String an = scan.nextLine();
      list.add(an);
      }
      String List[] = list.get(0).split(" ",0);
      X = Integer.parseInt(List[0]);
      N = Integer.parseInt(List[1]);
  //    System.out.println(N);
      int num[] = new int[N];
      if(N != 0){
      String Atai[] = list.get(1).split(" ",0);
      while(i < N){
        num[i] = Integer.parseInt(Atai[i]);
        i++;
      }
              
      Arrays.sort(num);
      check(num,X,N);
      }else{
       System.out.println(X);
        }

        scan.close();
    }
  
  public static void check(int[] num,int x,int n){
   //System.out.println(num[0]);
    List<Integer> numList = new ArrayList<Integer>(num.length);
    for (int i = 0; i < num.length; i++) {
       numList.add(num[i]);
    }
    int s,l;
     s = x;
     l = x;
    while(true) {
      if(numList.contains(s)){
        s = s-1;
        if(numList.contains(l)){
          l = l + 1;
         }else{
          System.out.println(l);
          break;
        }
        }else{
       System.out.println(s);
//       System.out.println("ok");
       break;
      }
     
      }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int N , X;
      int i = 0; 
      while (scan.hasNextLine()) {
      String an = scan.nextLine();
      list.add(an);
      }
      String List[] = list.get(0).split(" ",0);
      X = Integer.parseInt(List[0]);
      N = Integer.parseInt(List[1]);
  //    System.out.println(N);
      int num[] = new int[N];
      if(N != 0){
      String Atai[] = list.get(1).split(" ",0);
      while(i < N){
        num[i] = Integer.parseInt(Atai[i]);
        i++;
      }
              
      Arrays.sort(num);
      check(num,X,N);
      }else{
       System.out.println(X);
        }

        scan.close();
    }
  
  public static void check(int[] num,int x,int n){
   //System.out.println(num[0]);
    List<Integer> numList = new ArrayList<Integer>(num.length);
    for (int i = 0; i < num.length; i++) {
       numList.add(num[i]);
    }
    int s,l;
     s = x;
     l = x;
    while(true) {
      if(numList.contains(s)){
        s = s-1;
        if(numList.contains(l)){
          l = l + 1;
         }else{
          System.out.println(l);
          break;
        }
        }else{
       System.out.println(s);
//       System.out.println("ok");
       break;
      }
     
      }
    }
} Main
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int N , X;
      int i = 0; 
      while (scan.hasNextLine()) {
      String an = scan.nextLine();
      list.add(an);
      }
      String List[] = list.get(0).split(" ",0);
      X = Integer.parseInt(List[0]);
      N = Integer.parseInt(List[1]);
  //    System.out.println(N);
      int num[] = new int[N];
      if(N != 0){
      String Atai[] = list.get(1).split(" ",0);
      while(i < N){
        num[i] = Integer.parseInt(Atai[i]);
        i++;
      }
              
      Arrays.sort(num);
      check(num,X,N);
      }else{
       System.out.println(X);
        }

        scan.close();
    }
  
  public static void check(int[] num,int x,int n){
   //System.out.println(num[0]);
    List<Integer> numList = new ArrayList<Integer>(num.length);
    for (int i = 0; i < num.length; i++) {
       numList.add(num[i]);
    }
    int s,l;
     s = x;
     l = x;
    while(true) {
      if(numList.contains(s)){
        s = s-1;
        if(numList.contains(l)){
          l = l + 1;
         }else{
          System.out.println(l);
          break;
        }
        }else{
       System.out.println(s);
//       System.out.println("ok");
       break;
      }
     
      }
    }
}