import java.util.*;

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

        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(scanner.nextInt());
        }

        int diff = 0;
        int ans;

        while (true) {

            int left = x - diff;
            if (!set.contains(left)) {
                ans = left;
                break;
            }

            int right = x + diff;
            if (!set.contains(right)) {
                ans = right;
                break;
            }

            diff++;
        }

        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int n = scanner.nextInt();

        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(scanner.nextInt());
        }

        int diff = 0;
        int ans;

        while (true) {

            int left = x - diff;
            if (!set.contains(left)) {
                ans = left;
                break;
            }

            int right = x + diff;
            if (!set.contains(right)) {
                ans = right;
                break;
            }

            diff++;
        }

        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int n = scanner.nextInt();

        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(scanner.nextInt());
        }

        int diff = 0;
        int ans;

        while (true) {

            int left = x - diff;
            if (!set.contains(left)) {
                ans = left;
                break;
            }

            int right = x + diff;
            if (!set.contains(right)) {
                ans = right;
                break;
            }

            diff++;
        }

        System.out.println(ans);
    } main {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int n = scanner.nextInt();

        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(scanner.nextInt());
        }

        int diff = 0;
        int ans;

        while (true) {

            int left = x - diff;
            if (!set.contains(left)) {
                ans = left;
                break;
            }

            int right = x + diff;
            if (!set.contains(right)) {
                ans = right;
                break;
            }

            diff++;
        }

        System.out.println(ans);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int x = scanner.nextInt(); x scanner.nextInt() scanner.nextInt scanner int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner Set<Integer> set = new HashSet<>(); set new HashSet<>() for (int i = 0; i < n; i++) {
            set.add(scanner.nextInt());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            set.add(scanner.nextInt());
        } {
            set.add(scanner.nextInt());
        } set.add(scanner.nextInt()) set.add set scanner.nextInt() scanner.nextInt scanner int diff = 0; diff 0 int ans; ans while (true) {

            int left = x - diff;
            if (!set.contains(left)) {
                ans = left;
                break;
            }

            int right = x + diff;
            if (!set.contains(right)) {
                ans = right;
                break;
            }

            diff++;
        } true {

            int left = x - diff;
            if (!set.contains(left)) {
                ans = left;
                break;
            }

            int right = x + diff;
            if (!set.contains(right)) {
                ans = right;
                break;
            }

            diff++;
        } int left = x - diff; left x - diff x diff if (!set.contains(left)) {
                ans = left;
                break;
            } !set.contains(left) set.contains(left) set.contains set left {
                ans = left;
                break;
            } ans = left ans left break; int right = x + diff; right x + diff x diff if (!set.contains(right)) {
                ans = right;
                break;
            } !set.contains(right) set.contains(right) set.contains set right {
                ans = right;
                break;
            } ans = right ans right break; diff++ diff System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int n = scanner.nextInt();

        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(scanner.nextInt());
        }

        int diff = 0;
        int ans;

        while (true) {

            int left = x - diff;
            if (!set.contains(left)) {
                ans = left;
                break;
            }

            int right = x + diff;
            if (!set.contains(right)) {
                ans = right;
                break;
            }

            diff++;
        }

        System.out.println(ans);
    }
} public class Main {
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int n = scanner.nextInt();

        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(scanner.nextInt());
        }

        int diff = 0;
        int ans;

        while (true) {

            int left = x - diff;
            if (!set.contains(left)) {
                ans = left;
                break;
            }

            int right = x + diff;
            if (!set.contains(right)) {
                ans = right;
                break;
            }

            diff++;
        }

        System.out.println(ans);
    }
} Main
import java.util.*;

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

        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(scanner.nextInt());
        }

        int diff = 0;
        int ans;

        while (true) {

            int left = x - diff;
            if (!set.contains(left)) {
                ans = left;
                break;
            }

            int right = x + diff;
            if (!set.contains(right)) {
                ans = right;
                break;
            }

            diff++;
        }

        System.out.println(ans);
    }
}