import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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

        ArrayList<Integer> smaller = new ArrayList<>();
        ArrayList<Integer> bigger = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            int temp = scanner.nextInt();
            if (temp < X) {
                smaller.add(temp);
            } else {
                bigger.add(temp);
            }
        }

        scanner.close();

        Collections.sort(smaller);
        Collections.reverse(smaller);
        Collections.sort(bigger);

        int small = -1;
        int big = -1;
        for (int i = 0; i < smaller.size(); i++) {
            if (X - 1 - i != smaller.get(i)) {
                small = X - 1 - i;
                break;
            }
        }

        for (int i = 0; i < bigger.size(); i++) {
            if (X + i != bigger.get(i)) {
                big = X + i;
                break;
            }
        }

        if (bigger.size() > 0 && smaller.size() > 0) {
            if (small == -1) {
                small = smaller.get(smaller.size() - 1) - 1;
            }
            if (big == -1) {
                big = bigger.get(bigger.size() - 1) + 1;
            }

            if (X - small < big - X) {
                System.out.println(small);
            } else if (X - small > big - X) {
                System.out.println(big);
            } else {
                System.out.println(small);
            }
        } else if (bigger.size() == 0) {
            System.out.println(X);
        } else if (smaller.size() == 0) {
            if (bigger.contains(X)) {
                System.out.println(X - 1);
            } else {
                System.out.println(X);
            }
        }

    }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner 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();

        ArrayList<Integer> smaller = new ArrayList<>();
        ArrayList<Integer> bigger = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            int temp = scanner.nextInt();
            if (temp < X) {
                smaller.add(temp);
            } else {
                bigger.add(temp);
            }
        }

        scanner.close();

        Collections.sort(smaller);
        Collections.reverse(smaller);
        Collections.sort(bigger);

        int small = -1;
        int big = -1;
        for (int i = 0; i < smaller.size(); i++) {
            if (X - 1 - i != smaller.get(i)) {
                small = X - 1 - i;
                break;
            }
        }

        for (int i = 0; i < bigger.size(); i++) {
            if (X + i != bigger.get(i)) {
                big = X + i;
                break;
            }
        }

        if (bigger.size() > 0 && smaller.size() > 0) {
            if (small == -1) {
                small = smaller.get(smaller.size() - 1) - 1;
            }
            if (big == -1) {
                big = bigger.get(bigger.size() - 1) + 1;
            }

            if (X - small < big - X) {
                System.out.println(small);
            } else if (X - small > big - X) {
                System.out.println(big);
            } else {
                System.out.println(small);
            }
        } else if (bigger.size() == 0) {
            System.out.println(X);
        } else if (smaller.size() == 0) {
            if (bigger.contains(X)) {
                System.out.println(X - 1);
            } else {
                System.out.println(X);
            }
        }

    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int N = scanner.nextInt();

        ArrayList<Integer> smaller = new ArrayList<>();
        ArrayList<Integer> bigger = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            int temp = scanner.nextInt();
            if (temp < X) {
                smaller.add(temp);
            } else {
                bigger.add(temp);
            }
        }

        scanner.close();

        Collections.sort(smaller);
        Collections.reverse(smaller);
        Collections.sort(bigger);

        int small = -1;
        int big = -1;
        for (int i = 0; i < smaller.size(); i++) {
            if (X - 1 - i != smaller.get(i)) {
                small = X - 1 - i;
                break;
            }
        }

        for (int i = 0; i < bigger.size(); i++) {
            if (X + i != bigger.get(i)) {
                big = X + i;
                break;
            }
        }

        if (bigger.size() > 0 && smaller.size() > 0) {
            if (small == -1) {
                small = smaller.get(smaller.size() - 1) - 1;
            }
            if (big == -1) {
                big = bigger.get(bigger.size() - 1) + 1;
            }

            if (X - small < big - X) {
                System.out.println(small);
            } else if (X - small > big - X) {
                System.out.println(big);
            } else {
                System.out.println(small);
            }
        } else if (bigger.size() == 0) {
            System.out.println(X);
        } else if (smaller.size() == 0) {
            if (bigger.contains(X)) {
                System.out.println(X - 1);
            } else {
                System.out.println(X);
            }
        }

    } main {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int N = scanner.nextInt();

        ArrayList<Integer> smaller = new ArrayList<>();
        ArrayList<Integer> bigger = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            int temp = scanner.nextInt();
            if (temp < X) {
                smaller.add(temp);
            } else {
                bigger.add(temp);
            }
        }

        scanner.close();

        Collections.sort(smaller);
        Collections.reverse(smaller);
        Collections.sort(bigger);

        int small = -1;
        int big = -1;
        for (int i = 0; i < smaller.size(); i++) {
            if (X - 1 - i != smaller.get(i)) {
                small = X - 1 - i;
                break;
            }
        }

        for (int i = 0; i < bigger.size(); i++) {
            if (X + i != bigger.get(i)) {
                big = X + i;
                break;
            }
        }

        if (bigger.size() > 0 && smaller.size() > 0) {
            if (small == -1) {
                small = smaller.get(smaller.size() - 1) - 1;
            }
            if (big == -1) {
                big = bigger.get(bigger.size() - 1) + 1;
            }

            if (X - small < big - X) {
                System.out.println(small);
            } else if (X - small > big - X) {
                System.out.println(big);
            } else {
                System.out.println(small);
            }
        } else if (bigger.size() == 0) {
            System.out.println(X);
        } else if (smaller.size() == 0) {
            if (bigger.contains(X)) {
                System.out.println(X - 1);
            } else {
                System.out.println(X);
            }
        }

    } 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 ArrayList<Integer> smaller = new ArrayList<>(); smaller new ArrayList<>() ArrayList<Integer> bigger = new ArrayList<>(); bigger new ArrayList<>() for (int i = 0; i < N; i++) {
            int temp = scanner.nextInt();
            if (temp < X) {
                smaller.add(temp);
            } else {
                bigger.add(temp);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            int temp = scanner.nextInt();
            if (temp < X) {
                smaller.add(temp);
            } else {
                bigger.add(temp);
            }
        } {
            int temp = scanner.nextInt();
            if (temp < X) {
                smaller.add(temp);
            } else {
                bigger.add(temp);
            }
        } int temp = scanner.nextInt(); temp scanner.nextInt() scanner.nextInt scanner if (temp < X) {
                smaller.add(temp);
            } else {
                bigger.add(temp);
            } temp < X temp X {
                smaller.add(temp);
            } smaller.add(temp) smaller.add smaller temp {
                bigger.add(temp);
            } bigger.add(temp) bigger.add bigger temp scanner.close() scanner.close scanner Collections.sort(smaller) Collections.sort Collections smaller Collections.reverse(smaller) Collections.reverse Collections smaller Collections.sort(bigger) Collections.sort Collections bigger int small = -1; small -1 1 int big = -1; big -1 1 for (int i = 0; i < smaller.size(); i++) {
            if (X - 1 - i != smaller.get(i)) {
                small = X - 1 - i;
                break;
            }
        } int i = 0; int i = 0; i 0 i < smaller.size() i smaller.size() smaller.size smaller i++ i++ i {
            if (X - 1 - i != smaller.get(i)) {
                small = X - 1 - i;
                break;
            }
        } {
            if (X - 1 - i != smaller.get(i)) {
                small = X - 1 - i;
                break;
            }
        } if (X - 1 - i != smaller.get(i)) {
                small = X - 1 - i;
                break;
            } X - 1 - i != smaller.get(i) X - 1 - i X - 1 - i X 1 i smaller.get(i) smaller.get smaller i {
                small = X - 1 - i;
                break;
            } small = X - 1 - i small X - 1 - i X - 1 - i X 1 i break; for (int i = 0; i < bigger.size(); i++) {
            if (X + i != bigger.get(i)) {
                big = X + i;
                break;
            }
        } int i = 0; int i = 0; i 0 i < bigger.size() i bigger.size() bigger.size bigger i++ i++ i {
            if (X + i != bigger.get(i)) {
                big = X + i;
                break;
            }
        } {
            if (X + i != bigger.get(i)) {
                big = X + i;
                break;
            }
        } if (X + i != bigger.get(i)) {
                big = X + i;
                break;
            } X + i != bigger.get(i) X + i X i bigger.get(i) bigger.get bigger i {
                big = X + i;
                break;
            } big = X + i big X + i X i break; if (bigger.size() > 0 && smaller.size() > 0) {
            if (small == -1) {
                small = smaller.get(smaller.size() - 1) - 1;
            }
            if (big == -1) {
                big = bigger.get(bigger.size() - 1) + 1;
            }

            if (X - small < big - X) {
                System.out.println(small);
            } else if (X - small > big - X) {
                System.out.println(big);
            } else {
                System.out.println(small);
            }
        } else if (bigger.size() == 0) {
            System.out.println(X);
        } else if (smaller.size() == 0) {
            if (bigger.contains(X)) {
                System.out.println(X - 1);
            } else {
                System.out.println(X);
            }
        } bigger.size() > 0 && smaller.size() > 0 bigger.size() > 0 bigger.size() bigger.size bigger 0 smaller.size() > 0 smaller.size() smaller.size smaller 0 {
            if (small == -1) {
                small = smaller.get(smaller.size() - 1) - 1;
            }
            if (big == -1) {
                big = bigger.get(bigger.size() - 1) + 1;
            }

            if (X - small < big - X) {
                System.out.println(small);
            } else if (X - small > big - X) {
                System.out.println(big);
            } else {
                System.out.println(small);
            }
        } if (small == -1) {
                small = smaller.get(smaller.size() - 1) - 1;
            } small == -1 small -1 1 {
                small = smaller.get(smaller.size() - 1) - 1;
            } small = smaller.get(smaller.size() - 1) - 1 small smaller.get(smaller.size() - 1) - 1 smaller.get(smaller.size() - 1) smaller.get smaller smaller.size() - 1 smaller.size() smaller.size smaller 1 1 if (big == -1) {
                big = bigger.get(bigger.size() - 1) + 1;
            } big == -1 big -1 1 {
                big = bigger.get(bigger.size() - 1) + 1;
            } big = bigger.get(bigger.size() - 1) + 1 big bigger.get(bigger.size() - 1) + 1 bigger.get(bigger.size() - 1) bigger.get bigger bigger.size() - 1 bigger.size() bigger.size bigger 1 1 if (X - small < big - X) {
                System.out.println(small);
            } else if (X - small > big - X) {
                System.out.println(big);
            } else {
                System.out.println(small);
            } X - small < big - X X - small X small big - X big X {
                System.out.println(small);
            } System.out.println(small) System.out.println System.out System System.out small if (X - small > big - X) {
                System.out.println(big);
            } else {
                System.out.println(small);
            } X - small > big - X X - small X small big - X big X {
                System.out.println(big);
            } System.out.println(big) System.out.println System.out System System.out big {
                System.out.println(small);
            } System.out.println(small) System.out.println System.out System System.out small if (bigger.size() == 0) {
            System.out.println(X);
        } else if (smaller.size() == 0) {
            if (bigger.contains(X)) {
                System.out.println(X - 1);
            } else {
                System.out.println(X);
            }
        } bigger.size() == 0 bigger.size() bigger.size bigger 0 {
            System.out.println(X);
        } System.out.println(X) System.out.println System.out System System.out X if (smaller.size() == 0) {
            if (bigger.contains(X)) {
                System.out.println(X - 1);
            } else {
                System.out.println(X);
            }
        } smaller.size() == 0 smaller.size() smaller.size smaller 0 {
            if (bigger.contains(X)) {
                System.out.println(X - 1);
            } else {
                System.out.println(X);
            }
        } if (bigger.contains(X)) {
                System.out.println(X - 1);
            } else {
                System.out.println(X);
            } bigger.contains(X) bigger.contains bigger X {
                System.out.println(X - 1);
            } System.out.println(X - 1) System.out.println System.out System System.out X - 1 X 1 {
                System.out.println(X);
            } System.out.println(X) System.out.println System.out System System.out X 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();

        ArrayList<Integer> smaller = new ArrayList<>();
        ArrayList<Integer> bigger = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            int temp = scanner.nextInt();
            if (temp < X) {
                smaller.add(temp);
            } else {
                bigger.add(temp);
            }
        }

        scanner.close();

        Collections.sort(smaller);
        Collections.reverse(smaller);
        Collections.sort(bigger);

        int small = -1;
        int big = -1;
        for (int i = 0; i < smaller.size(); i++) {
            if (X - 1 - i != smaller.get(i)) {
                small = X - 1 - i;
                break;
            }
        }

        for (int i = 0; i < bigger.size(); i++) {
            if (X + i != bigger.get(i)) {
                big = X + i;
                break;
            }
        }

        if (bigger.size() > 0 && smaller.size() > 0) {
            if (small == -1) {
                small = smaller.get(smaller.size() - 1) - 1;
            }
            if (big == -1) {
                big = bigger.get(bigger.size() - 1) + 1;
            }

            if (X - small < big - X) {
                System.out.println(small);
            } else if (X - small > big - X) {
                System.out.println(big);
            } else {
                System.out.println(small);
            }
        } else if (bigger.size() == 0) {
            System.out.println(X);
        } else if (smaller.size() == 0) {
            if (bigger.contains(X)) {
                System.out.println(X - 1);
            } else {
                System.out.println(X);
            }
        }

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

        ArrayList<Integer> smaller = new ArrayList<>();
        ArrayList<Integer> bigger = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            int temp = scanner.nextInt();
            if (temp < X) {
                smaller.add(temp);
            } else {
                bigger.add(temp);
            }
        }

        scanner.close();

        Collections.sort(smaller);
        Collections.reverse(smaller);
        Collections.sort(bigger);

        int small = -1;
        int big = -1;
        for (int i = 0; i < smaller.size(); i++) {
            if (X - 1 - i != smaller.get(i)) {
                small = X - 1 - i;
                break;
            }
        }

        for (int i = 0; i < bigger.size(); i++) {
            if (X + i != bigger.get(i)) {
                big = X + i;
                break;
            }
        }

        if (bigger.size() > 0 && smaller.size() > 0) {
            if (small == -1) {
                small = smaller.get(smaller.size() - 1) - 1;
            }
            if (big == -1) {
                big = bigger.get(bigger.size() - 1) + 1;
            }

            if (X - small < big - X) {
                System.out.println(small);
            } else if (X - small > big - X) {
                System.out.println(big);
            } else {
                System.out.println(small);
            }
        } else if (bigger.size() == 0) {
            System.out.println(X);
        } else if (smaller.size() == 0) {
            if (bigger.contains(X)) {
                System.out.println(X - 1);
            } else {
                System.out.println(X);
            }
        }

    }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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

        ArrayList<Integer> smaller = new ArrayList<>();
        ArrayList<Integer> bigger = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            int temp = scanner.nextInt();
            if (temp < X) {
                smaller.add(temp);
            } else {
                bigger.add(temp);
            }
        }

        scanner.close();

        Collections.sort(smaller);
        Collections.reverse(smaller);
        Collections.sort(bigger);

        int small = -1;
        int big = -1;
        for (int i = 0; i < smaller.size(); i++) {
            if (X - 1 - i != smaller.get(i)) {
                small = X - 1 - i;
                break;
            }
        }

        for (int i = 0; i < bigger.size(); i++) {
            if (X + i != bigger.get(i)) {
                big = X + i;
                break;
            }
        }

        if (bigger.size() > 0 && smaller.size() > 0) {
            if (small == -1) {
                small = smaller.get(smaller.size() - 1) - 1;
            }
            if (big == -1) {
                big = bigger.get(bigger.size() - 1) + 1;
            }

            if (X - small < big - X) {
                System.out.println(small);
            } else if (X - small > big - X) {
                System.out.println(big);
            } else {
                System.out.println(small);
            }
        } else if (bigger.size() == 0) {
            System.out.println(X);
        } else if (smaller.size() == 0) {
            if (bigger.contains(X)) {
                System.out.println(X - 1);
            } else {
                System.out.println(X);
            }
        }

    }
}
