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