
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
    static 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;
        }
    }
    public static void main(String[] args) {
        FastReader fr = new FastReader();
        int x = fr.nextInt();
        int n = fr.nextInt();
        if(n==0){
            System.out.println(x);
        }
        else{
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                set.add(fr.nextInt());
            }
            if(!set.contains(x)){
                System.out.println(x);
            }
            else{
                int forward = x+1;
                while(set.contains(forward)){
                    forward++;
                }
                int backward = x-1;
                while(set.contains(backward)){
                    backward--;
                }
                int val1 = forward-x;
                int val2 = 0;
                if(backward<0){
                    val2+=(x);
                    val2+=(Math.abs(backward));
                }
                else{
                    val2=(x-backward);
                }
                if(val1<val2){
                    System.out.println(x+val1);
                }
                else{
                    System.out.println(x-val2);
                }
            }
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.HashSet; HashSet java.util import java.util.Set; Set java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {
    static 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;
        }
    }
    public static void main(String[] args) {
        FastReader fr = new FastReader();
        int x = fr.nextInt();
        int n = fr.nextInt();
        if(n==0){
            System.out.println(x);
        }
        else{
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                set.add(fr.nextInt());
            }
            if(!set.contains(x)){
                System.out.println(x);
            }
            else{
                int forward = x+1;
                while(set.contains(forward)){
                    forward++;
                }
                int backward = x-1;
                while(set.contains(backward)){
                    backward--;
                }
                int val1 = forward-x;
                int val2 = 0;
                if(backward<0){
                    val2+=(x);
                    val2+=(Math.abs(backward));
                }
                else{
                    val2=(x-backward);
                }
                if(val1<val2){
                    System.out.println(x+val1);
                }
                else{
                    System.out.println(x-val2);
                }
            }
        }
    }
} Main public static void main(String[] args) {
        FastReader fr = new FastReader();
        int x = fr.nextInt();
        int n = fr.nextInt();
        if(n==0){
            System.out.println(x);
        }
        else{
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                set.add(fr.nextInt());
            }
            if(!set.contains(x)){
                System.out.println(x);
            }
            else{
                int forward = x+1;
                while(set.contains(forward)){
                    forward++;
                }
                int backward = x-1;
                while(set.contains(backward)){
                    backward--;
                }
                int val1 = forward-x;
                int val2 = 0;
                if(backward<0){
                    val2+=(x);
                    val2+=(Math.abs(backward));
                }
                else{
                    val2=(x-backward);
                }
                if(val1<val2){
                    System.out.println(x+val1);
                }
                else{
                    System.out.println(x-val2);
                }
            }
        }
    } main {
        FastReader fr = new FastReader();
        int x = fr.nextInt();
        int n = fr.nextInt();
        if(n==0){
            System.out.println(x);
        }
        else{
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                set.add(fr.nextInt());
            }
            if(!set.contains(x)){
                System.out.println(x);
            }
            else{
                int forward = x+1;
                while(set.contains(forward)){
                    forward++;
                }
                int backward = x-1;
                while(set.contains(backward)){
                    backward--;
                }
                int val1 = forward-x;
                int val2 = 0;
                if(backward<0){
                    val2+=(x);
                    val2+=(Math.abs(backward));
                }
                else{
                    val2=(x-backward);
                }
                if(val1<val2){
                    System.out.println(x+val1);
                }
                else{
                    System.out.println(x-val2);
                }
            }
        }
    } FastReader fr = new FastReader(); fr new FastReader() int x = fr.nextInt(); x fr.nextInt() fr.nextInt fr int n = fr.nextInt(); n fr.nextInt() fr.nextInt fr if(n==0){
            System.out.println(x);
        }
        else{
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                set.add(fr.nextInt());
            }
            if(!set.contains(x)){
                System.out.println(x);
            }
            else{
                int forward = x+1;
                while(set.contains(forward)){
                    forward++;
                }
                int backward = x-1;
                while(set.contains(backward)){
                    backward--;
                }
                int val1 = forward-x;
                int val2 = 0;
                if(backward<0){
                    val2+=(x);
                    val2+=(Math.abs(backward));
                }
                else{
                    val2=(x-backward);
                }
                if(val1<val2){
                    System.out.println(x+val1);
                }
                else{
                    System.out.println(x-val2);
                }
            }
        } n==0 n 0 {
            System.out.println(x);
        } System.out.println(x) System.out.println System.out System System.out x {
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                set.add(fr.nextInt());
            }
            if(!set.contains(x)){
                System.out.println(x);
            }
            else{
                int forward = x+1;
                while(set.contains(forward)){
                    forward++;
                }
                int backward = x-1;
                while(set.contains(backward)){
                    backward--;
                }
                int val1 = forward-x;
                int val2 = 0;
                if(backward<0){
                    val2+=(x);
                    val2+=(Math.abs(backward));
                }
                else{
                    val2=(x-backward);
                }
                if(val1<val2){
                    System.out.println(x+val1);
                }
                else{
                    System.out.println(x-val2);
                }
            }
        } Set<Integer> set = new HashSet<>(); set new HashSet<>() for (int i = 0; i < n; i++) {
                set.add(fr.nextInt());
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                set.add(fr.nextInt());
            } {
                set.add(fr.nextInt());
            } set.add(fr.nextInt()) set.add set fr.nextInt() fr.nextInt fr if(!set.contains(x)){
                System.out.println(x);
            }
            else{
                int forward = x+1;
                while(set.contains(forward)){
                    forward++;
                }
                int backward = x-1;
                while(set.contains(backward)){
                    backward--;
                }
                int val1 = forward-x;
                int val2 = 0;
                if(backward<0){
                    val2+=(x);
                    val2+=(Math.abs(backward));
                }
                else{
                    val2=(x-backward);
                }
                if(val1<val2){
                    System.out.println(x+val1);
                }
                else{
                    System.out.println(x-val2);
                }
            } !set.contains(x) set.contains(x) set.contains set x {
                System.out.println(x);
            } System.out.println(x) System.out.println System.out System System.out x {
                int forward = x+1;
                while(set.contains(forward)){
                    forward++;
                }
                int backward = x-1;
                while(set.contains(backward)){
                    backward--;
                }
                int val1 = forward-x;
                int val2 = 0;
                if(backward<0){
                    val2+=(x);
                    val2+=(Math.abs(backward));
                }
                else{
                    val2=(x-backward);
                }
                if(val1<val2){
                    System.out.println(x+val1);
                }
                else{
                    System.out.println(x-val2);
                }
            } int forward = x+1; forward x+1 x 1 while(set.contains(forward)){
                    forward++;
                } set.contains(forward) set.contains set forward {
                    forward++;
                } forward++ forward int backward = x-1; backward x-1 x 1 while(set.contains(backward)){
                    backward--;
                } set.contains(backward) set.contains set backward {
                    backward--;
                } backward-- backward int val1 = forward-x; val1 forward-x forward x int val2 = 0; val2 0 if(backward<0){
                    val2+=(x);
                    val2+=(Math.abs(backward));
                }
                else{
                    val2=(x-backward);
                } backward<0 backward 0 {
                    val2+=(x);
                    val2+=(Math.abs(backward));
                } val2+=(x) val2 (x) val2+=(Math.abs(backward)) val2 (Math.abs(backward)) Math.abs Math backward {
                    val2=(x-backward);
                } val2=(x-backward) val2 (x-backward) x backward if(val1<val2){
                    System.out.println(x+val1);
                }
                else{
                    System.out.println(x-val2);
                } val1<val2 val1 val2 {
                    System.out.println(x+val1);
                } System.out.println(x+val1) System.out.println System.out System System.out x+val1 x val1 {
                    System.out.println(x-val2);
                } System.out.println(x-val2) System.out.println System.out System System.out x-val2 x val2 String[] args args static 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 {
    static 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;
        }
    }
    public static void main(String[] args) {
        FastReader fr = new FastReader();
        int x = fr.nextInt();
        int n = fr.nextInt();
        if(n==0){
            System.out.println(x);
        }
        else{
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                set.add(fr.nextInt());
            }
            if(!set.contains(x)){
                System.out.println(x);
            }
            else{
                int forward = x+1;
                while(set.contains(forward)){
                    forward++;
                }
                int backward = x-1;
                while(set.contains(backward)){
                    backward--;
                }
                int val1 = forward-x;
                int val2 = 0;
                if(backward<0){
                    val2+=(x);
                    val2+=(Math.abs(backward));
                }
                else{
                    val2=(x-backward);
                }
                if(val1<val2){
                    System.out.println(x+val1);
                }
                else{
                    System.out.println(x-val2);
                }
            }
        }
    }
} public class Main {
    static 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;
        }
    }
    public static void main(String[] args) {
        FastReader fr = new FastReader();
        int x = fr.nextInt();
        int n = fr.nextInt();
        if(n==0){
            System.out.println(x);
        }
        else{
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                set.add(fr.nextInt());
            }
            if(!set.contains(x)){
                System.out.println(x);
            }
            else{
                int forward = x+1;
                while(set.contains(forward)){
                    forward++;
                }
                int backward = x-1;
                while(set.contains(backward)){
                    backward--;
                }
                int val1 = forward-x;
                int val2 = 0;
                if(backward<0){
                    val2+=(x);
                    val2+=(Math.abs(backward));
                }
                else{
                    val2=(x-backward);
                }
                if(val1<val2){
                    System.out.println(x+val1);
                }
                else{
                    System.out.println(x-val2);
                }
            }
        }
    }
} Main

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
    static 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;
        }
    }
    public static void main(String[] args) {
        FastReader fr = new FastReader();
        int x = fr.nextInt();
        int n = fr.nextInt();
        if(n==0){
            System.out.println(x);
        }
        else{
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                set.add(fr.nextInt());
            }
            if(!set.contains(x)){
                System.out.println(x);
            }
            else{
                int forward = x+1;
                while(set.contains(forward)){
                    forward++;
                }
                int backward = x-1;
                while(set.contains(backward)){
                    backward--;
                }
                int val1 = forward-x;
                int val2 = 0;
                if(backward<0){
                    val2+=(x);
                    val2+=(Math.abs(backward));
                }
                else{
                    val2=(x-backward);
                }
                if(val1<val2){
                    System.out.println(x+val1);
                }
                else{
                    System.out.println(x-val2);
                }
            }
        }
    }
}