import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
    public static void main(String[] args) throws IOException{
        FastReader sc = new FastReader();
        int x = sc.nextInt();
        int n = sc.nextInt();
        Set<Integer> nums = new HashSet<Integer>();
        for (int i = 0; i < n; i++){
            nums.add(sc.nextInt());
        }
        System.out.println(solve(x, n, nums));
    }
    static int solve(int x, int n, Set<Integer> nums){
        if (!(nums.contains(x))) return x;
        int cloSmall = x - 1, cloLarge = x + 1;
        boolean sml = false, lg = false;
        while (!(sml)){
            if (!(nums.contains(cloSmall))){
                sml = true;
            }else{
                cloSmall--;
            }
        }
        while (!(lg)){
            if (!(nums.contains(cloLarge))){
                lg = true;
            }else{
                cloLarge++;
            }
        }
        if (x - cloSmall == cloLarge - x){
            return Math.min(cloSmall, cloLarge);
        }else{
            return (x - cloSmall < cloLarge - x ? cloSmall : cloLarge);
        }
    }
}
class FastReader{ 
    BufferedReader br; 
    StringTokenizer st; 
    public FastReader() { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } 
    String next(){ 
        while (st == null || !st.hasMoreElements()) { 
            try{ 
                st = new StringTokenizer(br.readLine()); 
            }catch (IOException  e){ 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
    int nextInt(){ 
        return Integer.parseInt(next()); 
    } 
    long nextLong(){ 
        return Long.parseLong(next()); 
    } 
    double nextDouble(){ 
      return Double.parseDouble(next()); 
    } 
    String nextLine(){ 
        String str = ""; 
        try{ 
            str = br.readLine(); 
        } 
        catch (IOException e){ 
            e.printStackTrace(); 
        } 
        return str; 
    } 
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main{
    public static void main(String[] args) throws IOException{
        FastReader sc = new FastReader();
        int x = sc.nextInt();
        int n = sc.nextInt();
        Set<Integer> nums = new HashSet<Integer>();
        for (int i = 0; i < n; i++){
            nums.add(sc.nextInt());
        }
        System.out.println(solve(x, n, nums));
    }
    static int solve(int x, int n, Set<Integer> nums){
        if (!(nums.contains(x))) return x;
        int cloSmall = x - 1, cloLarge = x + 1;
        boolean sml = false, lg = false;
        while (!(sml)){
            if (!(nums.contains(cloSmall))){
                sml = true;
            }else{
                cloSmall--;
            }
        }
        while (!(lg)){
            if (!(nums.contains(cloLarge))){
                lg = true;
            }else{
                cloLarge++;
            }
        }
        if (x - cloSmall == cloLarge - x){
            return Math.min(cloSmall, cloLarge);
        }else{
            return (x - cloSmall < cloLarge - x ? cloSmall : cloLarge);
        }
    }
} Main public static void main(String[] args) throws IOException{
        FastReader sc = new FastReader();
        int x = sc.nextInt();
        int n = sc.nextInt();
        Set<Integer> nums = new HashSet<Integer>();
        for (int i = 0; i < n; i++){
            nums.add(sc.nextInt());
        }
        System.out.println(solve(x, n, nums));
    } main {
        FastReader sc = new FastReader();
        int x = sc.nextInt();
        int n = sc.nextInt();
        Set<Integer> nums = new HashSet<Integer>();
        for (int i = 0; i < n; i++){
            nums.add(sc.nextInt());
        }
        System.out.println(solve(x, n, nums));
    } FastReader sc = new FastReader(); sc new FastReader() int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc Set<Integer> nums = new HashSet<Integer>(); nums new HashSet<Integer>() for (int i = 0; i < n; i++){
            nums.add(sc.nextInt());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            nums.add(sc.nextInt());
        } {
            nums.add(sc.nextInt());
        } nums.add(sc.nextInt()) nums.add nums sc.nextInt() sc.nextInt sc System.out.println(solve(x, n, nums)) System.out.println System.out System System.out solve(x, n, nums) solve x n nums String[] args args static int solve(int x, int n, Set<Integer> nums){
        if (!(nums.contains(x))) return x;
        int cloSmall = x - 1, cloLarge = x + 1;
        boolean sml = false, lg = false;
        while (!(sml)){
            if (!(nums.contains(cloSmall))){
                sml = true;
            }else{
                cloSmall--;
            }
        }
        while (!(lg)){
            if (!(nums.contains(cloLarge))){
                lg = true;
            }else{
                cloLarge++;
            }
        }
        if (x - cloSmall == cloLarge - x){
            return Math.min(cloSmall, cloLarge);
        }else{
            return (x - cloSmall < cloLarge - x ? cloSmall : cloLarge);
        }
    } solve {
        if (!(nums.contains(x))) return x;
        int cloSmall = x - 1, cloLarge = x + 1;
        boolean sml = false, lg = false;
        while (!(sml)){
            if (!(nums.contains(cloSmall))){
                sml = true;
            }else{
                cloSmall--;
            }
        }
        while (!(lg)){
            if (!(nums.contains(cloLarge))){
                lg = true;
            }else{
                cloLarge++;
            }
        }
        if (x - cloSmall == cloLarge - x){
            return Math.min(cloSmall, cloLarge);
        }else{
            return (x - cloSmall < cloLarge - x ? cloSmall : cloLarge);
        }
    } if (!(nums.contains(x))) return x; !(nums.contains(x)) (nums.contains(x)) nums.contains nums x return x; x int cloSmall = x - 1 cloSmall x - 1 x 1 cloLarge = x + 1; cloLarge x + 1 x 1 boolean sml = false sml false lg = false; lg false while (!(sml)){
            if (!(nums.contains(cloSmall))){
                sml = true;
            }else{
                cloSmall--;
            }
        } !(sml) (sml) {
            if (!(nums.contains(cloSmall))){
                sml = true;
            }else{
                cloSmall--;
            }
        } if (!(nums.contains(cloSmall))){
                sml = true;
            }else{
                cloSmall--;
            } !(nums.contains(cloSmall)) (nums.contains(cloSmall)) nums.contains nums cloSmall {
                sml = true;
            } sml = true sml true {
                cloSmall--;
            } cloSmall-- cloSmall while (!(lg)){
            if (!(nums.contains(cloLarge))){
                lg = true;
            }else{
                cloLarge++;
            }
        } !(lg) (lg) {
            if (!(nums.contains(cloLarge))){
                lg = true;
            }else{
                cloLarge++;
            }
        } if (!(nums.contains(cloLarge))){
                lg = true;
            }else{
                cloLarge++;
            } !(nums.contains(cloLarge)) (nums.contains(cloLarge)) nums.contains nums cloLarge {
                lg = true;
            } lg = true lg true {
                cloLarge++;
            } cloLarge++ cloLarge if (x - cloSmall == cloLarge - x){
            return Math.min(cloSmall, cloLarge);
        }else{
            return (x - cloSmall < cloLarge - x ? cloSmall : cloLarge);
        } x - cloSmall == cloLarge - x x - cloSmall x cloSmall cloLarge - x cloLarge x {
            return Math.min(cloSmall, cloLarge);
        } return Math.min(cloSmall, cloLarge); Math.min(cloSmall, cloLarge) Math.min Math cloSmall cloLarge {
            return (x - cloSmall < cloLarge - x ? cloSmall : cloLarge);
        } return (x - cloSmall < cloLarge - x ? cloSmall : cloLarge); (x - cloSmall < cloLarge - x ? cloSmall : cloLarge) x - cloSmall < cloLarge - x x - cloSmall x cloSmall cloLarge - x cloLarge x cloSmall cloLarge int x x int n n Set<Integer> nums nums class FastReader{ 
    BufferedReader br; 
    StringTokenizer st; 
    public FastReader() { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } 
    String next(){ 
        while (st == null || !st.hasMoreElements()) { 
            try{ 
                st = new StringTokenizer(br.readLine()); 
            }catch (IOException  e){ 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
    int nextInt(){ 
        return Integer.parseInt(next()); 
    } 
    long nextLong(){ 
        return Long.parseLong(next()); 
    } 
    double nextDouble(){ 
      return Double.parseDouble(next()); 
    } 
    String nextLine(){ 
        String str = ""; 
        try{ 
            str = br.readLine(); 
        } 
        catch (IOException e){ 
            e.printStackTrace(); 
        } 
        return str; 
    } 
} FastReader BufferedReader br; br StringTokenizer st; st public FastReader() { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } FastReader { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String next(){ 
        while (st == null || !st.hasMoreElements()) { 
            try{ 
                st = new StringTokenizer(br.readLine()); 
            }catch (IOException  e){ 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } next { 
        while (st == null || !st.hasMoreElements()) { 
            try{ 
                st = new StringTokenizer(br.readLine()); 
            }catch (IOException  e){ 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } while (st == null || !st.hasMoreElements()) { 
            try{ 
                st = new StringTokenizer(br.readLine()); 
            }catch (IOException  e){ 
                e.printStackTrace(); 
            } 
        } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st { 
            try{ 
                st = new StringTokenizer(br.readLine()); 
            }catch (IOException  e){ 
                e.printStackTrace(); 
            } 
        } try{ 
                st = new StringTokenizer(br.readLine()); 
            }catch (IOException  e){ 
                e.printStackTrace(); 
            } catch (IOException  e){ 
                e.printStackTrace(); 
            } IOException  e { 
                e.printStackTrace(); 
            } e.printStackTrace() e.printStackTrace e { 
                st = new StringTokenizer(br.readLine()); 
            } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt(){ 
        return Integer.parseInt(next()); 
    } nextInt { 
        return Integer.parseInt(next()); 
    } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong(){ 
        return Long.parseLong(next()); 
    } nextLong { 
        return Long.parseLong(next()); 
    } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble(){ 
      return Double.parseDouble(next()); 
    } nextDouble { 
      return Double.parseDouble(next()); 
    } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String nextLine(){ 
        String str = ""; 
        try{ 
            str = br.readLine(); 
        } 
        catch (IOException e){ 
            e.printStackTrace(); 
        } 
        return str; 
    } nextLine { 
        String str = ""; 
        try{ 
            str = br.readLine(); 
        } 
        catch (IOException e){ 
            e.printStackTrace(); 
        } 
        return str; 
    } String str = ""; str "" try{ 
            str = br.readLine(); 
        } 
        catch (IOException e){ 
            e.printStackTrace(); 
        } catch (IOException e){ 
            e.printStackTrace(); 
        } IOException e { 
            e.printStackTrace(); 
        } e.printStackTrace() e.printStackTrace e { 
            str = br.readLine(); 
        } str = br.readLine() str br.readLine() br.readLine br return str; str public class Main{
    public static void main(String[] args) throws IOException{
        FastReader sc = new FastReader();
        int x = sc.nextInt();
        int n = sc.nextInt();
        Set<Integer> nums = new HashSet<Integer>();
        for (int i = 0; i < n; i++){
            nums.add(sc.nextInt());
        }
        System.out.println(solve(x, n, nums));
    }
    static int solve(int x, int n, Set<Integer> nums){
        if (!(nums.contains(x))) return x;
        int cloSmall = x - 1, cloLarge = x + 1;
        boolean sml = false, lg = false;
        while (!(sml)){
            if (!(nums.contains(cloSmall))){
                sml = true;
            }else{
                cloSmall--;
            }
        }
        while (!(lg)){
            if (!(nums.contains(cloLarge))){
                lg = true;
            }else{
                cloLarge++;
            }
        }
        if (x - cloSmall == cloLarge - x){
            return Math.min(cloSmall, cloLarge);
        }else{
            return (x - cloSmall < cloLarge - x ? cloSmall : cloLarge);
        }
    }
} public class Main{
    public static void main(String[] args) throws IOException{
        FastReader sc = new FastReader();
        int x = sc.nextInt();
        int n = sc.nextInt();
        Set<Integer> nums = new HashSet<Integer>();
        for (int i = 0; i < n; i++){
            nums.add(sc.nextInt());
        }
        System.out.println(solve(x, n, nums));
    }
    static int solve(int x, int n, Set<Integer> nums){
        if (!(nums.contains(x))) return x;
        int cloSmall = x - 1, cloLarge = x + 1;
        boolean sml = false, lg = false;
        while (!(sml)){
            if (!(nums.contains(cloSmall))){
                sml = true;
            }else{
                cloSmall--;
            }
        }
        while (!(lg)){
            if (!(nums.contains(cloLarge))){
                lg = true;
            }else{
                cloLarge++;
            }
        }
        if (x - cloSmall == cloLarge - x){
            return Math.min(cloSmall, cloLarge);
        }else{
            return (x - cloSmall < cloLarge - x ? cloSmall : cloLarge);
        }
    }
} Main
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
    public static void main(String[] args) throws IOException{
        FastReader sc = new FastReader();
        int x = sc.nextInt();
        int n = sc.nextInt();
        Set<Integer> nums = new HashSet<Integer>();
        for (int i = 0; i < n; i++){
            nums.add(sc.nextInt());
        }
        System.out.println(solve(x, n, nums));
    }
    static int solve(int x, int n, Set<Integer> nums){
        if (!(nums.contains(x))) return x;
        int cloSmall = x - 1, cloLarge = x + 1;
        boolean sml = false, lg = false;
        while (!(sml)){
            if (!(nums.contains(cloSmall))){
                sml = true;
            }else{
                cloSmall--;
            }
        }
        while (!(lg)){
            if (!(nums.contains(cloLarge))){
                lg = true;
            }else{
                cloLarge++;
            }
        }
        if (x - cloSmall == cloLarge - x){
            return Math.min(cloSmall, cloLarge);
        }else{
            return (x - cloSmall < cloLarge - x ? cloSmall : cloLarge);
        }
    }
}
class FastReader{ 
    BufferedReader br; 
    StringTokenizer st; 
    public FastReader() { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } 
    String next(){ 
        while (st == null || !st.hasMoreElements()) { 
            try{ 
                st = new StringTokenizer(br.readLine()); 
            }catch (IOException  e){ 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
    int nextInt(){ 
        return Integer.parseInt(next()); 
    } 
    long nextLong(){ 
        return Long.parseLong(next()); 
    } 
    double nextDouble(){ 
      return Double.parseDouble(next()); 
    } 
    String nextLine(){ 
        String str = ""; 
        try{ 
            str = br.readLine(); 
        } 
        catch (IOException e){ 
            e.printStackTrace(); 
        } 
        return str; 
    } 
}
