import java.util.*;
import java.lang.Integer; 

public class Main {
  public static void main(String[] args){
    
    int answer = 0; // 返却値
    // 入力
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(!sc.hasNext()){
      System.out.println(answer);
       return;
    }
    int n = sc.nextInt();
    
    // nが0のとき
    if(n == 0){
      answer = x;
      System.out.println(answer);
      return;
    }
    
    // 入力値の読み込み
    Set<Integer> pSet = new HashSet<Integer>();
    while(sc.hasNext()){
      pSet.add(sc.nextInt());
    }
    
    // 数字を検索する
    int a = 0;
    while(true){
      if(!pSet.contains(x - a)){
        answer = x - a;
        break;
      }
      if(!pSet.contains(x + a)){
        answer = x + a;
        break;
      }
      a++;
    }
    // 出力
    System.out.println(answer);
  }
} import java.util.*; util.* java import java.lang.Integer; Integer java.lang public class Main {
  public static void main(String[] args){
    
    int answer = 0; // 返却値
    // 入力
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(!sc.hasNext()){
      System.out.println(answer);
       return;
    }
    int n = sc.nextInt();
    
    // nが0のとき
    if(n == 0){
      answer = x;
      System.out.println(answer);
      return;
    }
    
    // 入力値の読み込み
    Set<Integer> pSet = new HashSet<Integer>();
    while(sc.hasNext()){
      pSet.add(sc.nextInt());
    }
    
    // 数字を検索する
    int a = 0;
    while(true){
      if(!pSet.contains(x - a)){
        answer = x - a;
        break;
      }
      if(!pSet.contains(x + a)){
        answer = x + a;
        break;
      }
      a++;
    }
    // 出力
    System.out.println(answer);
  }
} Main public static void main(String[] args){
    
    int answer = 0; // 返却値
    // 入力
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(!sc.hasNext()){
      System.out.println(answer);
       return;
    }
    int n = sc.nextInt();
    
    // nが0のとき
    if(n == 0){
      answer = x;
      System.out.println(answer);
      return;
    }
    
    // 入力値の読み込み
    Set<Integer> pSet = new HashSet<Integer>();
    while(sc.hasNext()){
      pSet.add(sc.nextInt());
    }
    
    // 数字を検索する
    int a = 0;
    while(true){
      if(!pSet.contains(x - a)){
        answer = x - a;
        break;
      }
      if(!pSet.contains(x + a)){
        answer = x + a;
        break;
      }
      a++;
    }
    // 出力
    System.out.println(answer);
  } main {
    
    int answer = 0; // 返却値
    // 入力
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(!sc.hasNext()){
      System.out.println(answer);
       return;
    }
    int n = sc.nextInt();
    
    // nが0のとき
    if(n == 0){
      answer = x;
      System.out.println(answer);
      return;
    }
    
    // 入力値の読み込み
    Set<Integer> pSet = new HashSet<Integer>();
    while(sc.hasNext()){
      pSet.add(sc.nextInt());
    }
    
    // 数字を検索する
    int a = 0;
    while(true){
      if(!pSet.contains(x - a)){
        answer = x - a;
        break;
      }
      if(!pSet.contains(x + a)){
        answer = x + a;
        break;
      }
      a++;
    }
    // 出力
    System.out.println(answer);
  } int answer = 0; answer 0 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc if(!sc.hasNext()){
      System.out.println(answer);
       return;
    } !sc.hasNext() sc.hasNext() sc.hasNext sc {
      System.out.println(answer);
       return;
    } System.out.println(answer) System.out.println System.out System System.out answer return; int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc if(n == 0){
      answer = x;
      System.out.println(answer);
      return;
    } n == 0 n 0 {
      answer = x;
      System.out.println(answer);
      return;
    } answer = x answer x System.out.println(answer) System.out.println System.out System System.out answer return; Set<Integer> pSet = new HashSet<Integer>(); pSet new HashSet<Integer>() while(sc.hasNext()){
      pSet.add(sc.nextInt());
    } sc.hasNext() sc.hasNext sc {
      pSet.add(sc.nextInt());
    } pSet.add(sc.nextInt()) pSet.add pSet sc.nextInt() sc.nextInt sc int a = 0; a 0 while(true){
      if(!pSet.contains(x - a)){
        answer = x - a;
        break;
      }
      if(!pSet.contains(x + a)){
        answer = x + a;
        break;
      }
      a++;
    } true {
      if(!pSet.contains(x - a)){
        answer = x - a;
        break;
      }
      if(!pSet.contains(x + a)){
        answer = x + a;
        break;
      }
      a++;
    } if(!pSet.contains(x - a)){
        answer = x - a;
        break;
      } !pSet.contains(x - a) pSet.contains(x - a) pSet.contains pSet x - a x a {
        answer = x - a;
        break;
      } answer = x - a answer x - a x a break; if(!pSet.contains(x + a)){
        answer = x + a;
        break;
      } !pSet.contains(x + a) pSet.contains(x + a) pSet.contains pSet x + a x a {
        answer = x + a;
        break;
      } answer = x + a answer x + a x a break; a++ a System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
  public static void main(String[] args){
    
    int answer = 0; // 返却値
    // 入力
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(!sc.hasNext()){
      System.out.println(answer);
       return;
    }
    int n = sc.nextInt();
    
    // nが0のとき
    if(n == 0){
      answer = x;
      System.out.println(answer);
      return;
    }
    
    // 入力値の読み込み
    Set<Integer> pSet = new HashSet<Integer>();
    while(sc.hasNext()){
      pSet.add(sc.nextInt());
    }
    
    // 数字を検索する
    int a = 0;
    while(true){
      if(!pSet.contains(x - a)){
        answer = x - a;
        break;
      }
      if(!pSet.contains(x + a)){
        answer = x + a;
        break;
      }
      a++;
    }
    // 出力
    System.out.println(answer);
  }
} public class Main {
  public static void main(String[] args){
    
    int answer = 0; // 返却値
    // 入力
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(!sc.hasNext()){
      System.out.println(answer);
       return;
    }
    int n = sc.nextInt();
    
    // nが0のとき
    if(n == 0){
      answer = x;
      System.out.println(answer);
      return;
    }
    
    // 入力値の読み込み
    Set<Integer> pSet = new HashSet<Integer>();
    while(sc.hasNext()){
      pSet.add(sc.nextInt());
    }
    
    // 数字を検索する
    int a = 0;
    while(true){
      if(!pSet.contains(x - a)){
        answer = x - a;
        break;
      }
      if(!pSet.contains(x + a)){
        answer = x + a;
        break;
      }
      a++;
    }
    // 出力
    System.out.println(answer);
  }
} Main
import java.util.*;
import java.lang.Integer; 

public class Main {
  public static void main(String[] args){
    
    int answer = 0; // 返却値
    // 入力
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(!sc.hasNext()){
      System.out.println(answer);
       return;
    }
    int n = sc.nextInt();
    
    // nが0のとき
    if(n == 0){
      answer = x;
      System.out.println(answer);
      return;
    }
    
    // 入力値の読み込み
    Set<Integer> pSet = new HashSet<Integer>();
    while(sc.hasNext()){
      pSet.add(sc.nextInt());
    }
    
    // 数字を検索する
    int a = 0;
    while(true){
      if(!pSet.contains(x - a)){
        answer = x - a;
        break;
      }
      if(!pSet.contains(x + a)){
        answer = x + a;
        break;
      }
      a++;
    }
    // 出力
    System.out.println(answer);
  }
}