import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static List<Integer> list = new ArrayList<Integer>();
    static int x = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        if (!(list.contains(x))) {
            System.out.println(x);
        } else {
            System.out.println(dfs(1));
        }
    }

    private static int dfs(int n) {
        if (!(list.contains(x - n))) {
            return x - n;
        } else if (!(list.contains(x + n))) {
            return x + n;
        }
        return dfs(++n);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
    static List<Integer> list = new ArrayList<Integer>();
    static int x = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        if (!(list.contains(x))) {
            System.out.println(x);
        } else {
            System.out.println(dfs(1));
        }
    }

    private static int dfs(int n) {
        if (!(list.contains(x - n))) {
            return x - n;
        } else if (!(list.contains(x + n))) {
            return x + n;
        }
        return dfs(++n);
    }
} Main static List<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() static int x = 0; x 0 public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        if (!(list.contains(x))) {
            System.out.println(x);
        } else {
            System.out.println(dfs(1));
        }
    } main {
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        if (!(list.contains(x))) {
            System.out.println(x);
        } else {
            System.out.println(dfs(1));
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) x = sc.nextInt() x sc.nextInt() sc.nextInt sc int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            list.add(sc.nextInt());
        } {
            list.add(sc.nextInt());
        } list.add(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc if (!(list.contains(x))) {
            System.out.println(x);
        } else {
            System.out.println(dfs(1));
        } !(list.contains(x)) (list.contains(x)) list.contains list x {
            System.out.println(x);
        } System.out.println(x) System.out.println System.out System System.out x {
            System.out.println(dfs(1));
        } System.out.println(dfs(1)) System.out.println System.out System System.out dfs(1) dfs 1 String[] args args private static int dfs(int n) {
        if (!(list.contains(x - n))) {
            return x - n;
        } else if (!(list.contains(x + n))) {
            return x + n;
        }
        return dfs(++n);
    } dfs {
        if (!(list.contains(x - n))) {
            return x - n;
        } else if (!(list.contains(x + n))) {
            return x + n;
        }
        return dfs(++n);
    } if (!(list.contains(x - n))) {
            return x - n;
        } else if (!(list.contains(x + n))) {
            return x + n;
        } !(list.contains(x - n)) (list.contains(x - n)) list.contains list x - n x n {
            return x - n;
        } return x - n; x - n x n if (!(list.contains(x + n))) {
            return x + n;
        } !(list.contains(x + n)) (list.contains(x + n)) list.contains list x + n x n {
            return x + n;
        } return x + n; x + n x n return dfs(++n); dfs(++n) dfs ++n n int n n public class Main {
    static List<Integer> list = new ArrayList<Integer>();
    static int x = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        if (!(list.contains(x))) {
            System.out.println(x);
        } else {
            System.out.println(dfs(1));
        }
    }

    private static int dfs(int n) {
        if (!(list.contains(x - n))) {
            return x - n;
        } else if (!(list.contains(x + n))) {
            return x + n;
        }
        return dfs(++n);
    }
} public class Main {
    static List<Integer> list = new ArrayList<Integer>();
    static int x = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        if (!(list.contains(x))) {
            System.out.println(x);
        } else {
            System.out.println(dfs(1));
        }
    }

    private static int dfs(int n) {
        if (!(list.contains(x - n))) {
            return x - n;
        } else if (!(list.contains(x + n))) {
            return x + n;
        }
        return dfs(++n);
    }
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static List<Integer> list = new ArrayList<Integer>();
    static int x = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        if (!(list.contains(x))) {
            System.out.println(x);
        } else {
            System.out.println(dfs(1));
        }
    }

    private static int dfs(int n) {
        if (!(list.contains(x - n))) {
            return x - n;
        } else if (!(list.contains(x + n))) {
            return x + n;
        }
        return dfs(++n);
    }
}