import java.util.Arrays;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = 0;
        int N = 0;
        X = scanner.nextInt();
        N = scanner.nextInt();
        if (N != 0) {
            int[] suuretu = new int[N];
            for (int i = 0; i < N; i++) {
                suuretu[i] = scanner.nextInt();
            }
            Arrays.sort(suuretu);
//            System.out.println("  " +suuretu[N - 1] + " " + suuretu[0]);

            int[] junban = new int[suuretu[N - 1] - suuretu[0] + 3];
            int index = 0;
            for (int i = suuretu[0] - 1; i <= suuretu[N - 1] + 1; i++) {
                junban[index] = i;
//                System.out.println("  " + i);
                index++;
            }

            List<Integer> suuretuList = toList(suuretu);
            List<Integer> junbanList = toList(junban);
            junbanList.removeAll(suuretuList);
            List<Integer> sabunList = new ArrayList<>();
            List<Integer> sabunAtaiList = new ArrayList<>();
            for (Integer info : junbanList) {
//                System.out.println(info);
                sabunList.add(Math.abs(info - X));
                sabunAtaiList.add(info);
            }
            Object[] sabun = sabunList.toArray();
            Object[] sabunAtai = sabunAtaiList.toArray();


//            if (sabunList.size() > 0) {
                int intMin = (int) sabun[0];
                int minIndex = 0;
                for (int i = 1; i < sabun.length; i++) {

                    if (intMin > (int) sabun[i]) {
                        intMin = (int) sabun[i];
                        minIndex = i;
                    }
                }
                System.out.println(sabunAtai[minIndex]);
//            } else {
//
//                System.out.println(X);
//            }

        } else {

            System.out.println(X);
        }


    }

    public static ArrayList<Integer> toList(int[] arr){
        // int[] -> ArrayList<Integer>
        ArrayList<Integer> list = new ArrayList<Integer>();
        for (int t : arr) list.add(t);
        return list;
    }
} import java.util.Arrays; Arrays java.util import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = 0;
        int N = 0;
        X = scanner.nextInt();
        N = scanner.nextInt();
        if (N != 0) {
            int[] suuretu = new int[N];
            for (int i = 0; i < N; i++) {
                suuretu[i] = scanner.nextInt();
            }
            Arrays.sort(suuretu);
//            System.out.println("  " +suuretu[N - 1] + " " + suuretu[0]);

            int[] junban = new int[suuretu[N - 1] - suuretu[0] + 3];
            int index = 0;
            for (int i = suuretu[0] - 1; i <= suuretu[N - 1] + 1; i++) {
                junban[index] = i;
//                System.out.println("  " + i);
                index++;
            }

            List<Integer> suuretuList = toList(suuretu);
            List<Integer> junbanList = toList(junban);
            junbanList.removeAll(suuretuList);
            List<Integer> sabunList = new ArrayList<>();
            List<Integer> sabunAtaiList = new ArrayList<>();
            for (Integer info : junbanList) {
//                System.out.println(info);
                sabunList.add(Math.abs(info - X));
                sabunAtaiList.add(info);
            }
            Object[] sabun = sabunList.toArray();
            Object[] sabunAtai = sabunAtaiList.toArray();


//            if (sabunList.size() > 0) {
                int intMin = (int) sabun[0];
                int minIndex = 0;
                for (int i = 1; i < sabun.length; i++) {

                    if (intMin > (int) sabun[i]) {
                        intMin = (int) sabun[i];
                        minIndex = i;
                    }
                }
                System.out.println(sabunAtai[minIndex]);
//            } else {
//
//                System.out.println(X);
//            }

        } else {

            System.out.println(X);
        }


    }

    public static ArrayList<Integer> toList(int[] arr){
        // int[] -> ArrayList<Integer>
        ArrayList<Integer> list = new ArrayList<Integer>();
        for (int t : arr) list.add(t);
        return list;
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = 0;
        int N = 0;
        X = scanner.nextInt();
        N = scanner.nextInt();
        if (N != 0) {
            int[] suuretu = new int[N];
            for (int i = 0; i < N; i++) {
                suuretu[i] = scanner.nextInt();
            }
            Arrays.sort(suuretu);
//            System.out.println("  " +suuretu[N - 1] + " " + suuretu[0]);

            int[] junban = new int[suuretu[N - 1] - suuretu[0] + 3];
            int index = 0;
            for (int i = suuretu[0] - 1; i <= suuretu[N - 1] + 1; i++) {
                junban[index] = i;
//                System.out.println("  " + i);
                index++;
            }

            List<Integer> suuretuList = toList(suuretu);
            List<Integer> junbanList = toList(junban);
            junbanList.removeAll(suuretuList);
            List<Integer> sabunList = new ArrayList<>();
            List<Integer> sabunAtaiList = new ArrayList<>();
            for (Integer info : junbanList) {
//                System.out.println(info);
                sabunList.add(Math.abs(info - X));
                sabunAtaiList.add(info);
            }
            Object[] sabun = sabunList.toArray();
            Object[] sabunAtai = sabunAtaiList.toArray();


//            if (sabunList.size() > 0) {
                int intMin = (int) sabun[0];
                int minIndex = 0;
                for (int i = 1; i < sabun.length; i++) {

                    if (intMin > (int) sabun[i]) {
                        intMin = (int) sabun[i];
                        minIndex = i;
                    }
                }
                System.out.println(sabunAtai[minIndex]);
//            } else {
//
//                System.out.println(X);
//            }

        } else {

            System.out.println(X);
        }


    } main {
        Scanner scanner = new Scanner(System.in);
        int X = 0;
        int N = 0;
        X = scanner.nextInt();
        N = scanner.nextInt();
        if (N != 0) {
            int[] suuretu = new int[N];
            for (int i = 0; i < N; i++) {
                suuretu[i] = scanner.nextInt();
            }
            Arrays.sort(suuretu);
//            System.out.println("  " +suuretu[N - 1] + " " + suuretu[0]);

            int[] junban = new int[suuretu[N - 1] - suuretu[0] + 3];
            int index = 0;
            for (int i = suuretu[0] - 1; i <= suuretu[N - 1] + 1; i++) {
                junban[index] = i;
//                System.out.println("  " + i);
                index++;
            }

            List<Integer> suuretuList = toList(suuretu);
            List<Integer> junbanList = toList(junban);
            junbanList.removeAll(suuretuList);
            List<Integer> sabunList = new ArrayList<>();
            List<Integer> sabunAtaiList = new ArrayList<>();
            for (Integer info : junbanList) {
//                System.out.println(info);
                sabunList.add(Math.abs(info - X));
                sabunAtaiList.add(info);
            }
            Object[] sabun = sabunList.toArray();
            Object[] sabunAtai = sabunAtaiList.toArray();


//            if (sabunList.size() > 0) {
                int intMin = (int) sabun[0];
                int minIndex = 0;
                for (int i = 1; i < sabun.length; i++) {

                    if (intMin > (int) sabun[i]) {
                        intMin = (int) sabun[i];
                        minIndex = i;
                    }
                }
                System.out.println(sabunAtai[minIndex]);
//            } else {
//
//                System.out.println(X);
//            }

        } else {

            System.out.println(X);
        }


    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int X = 0; X 0 int N = 0; N 0 X = scanner.nextInt() X scanner.nextInt() scanner.nextInt scanner N = scanner.nextInt() N scanner.nextInt() scanner.nextInt scanner if (N != 0) {
            int[] suuretu = new int[N];
            for (int i = 0; i < N; i++) {
                suuretu[i] = scanner.nextInt();
            }
            Arrays.sort(suuretu);
//            System.out.println("  " +suuretu[N - 1] + " " + suuretu[0]);

            int[] junban = new int[suuretu[N - 1] - suuretu[0] + 3];
            int index = 0;
            for (int i = suuretu[0] - 1; i <= suuretu[N - 1] + 1; i++) {
                junban[index] = i;
//                System.out.println("  " + i);
                index++;
            }

            List<Integer> suuretuList = toList(suuretu);
            List<Integer> junbanList = toList(junban);
            junbanList.removeAll(suuretuList);
            List<Integer> sabunList = new ArrayList<>();
            List<Integer> sabunAtaiList = new ArrayList<>();
            for (Integer info : junbanList) {
//                System.out.println(info);
                sabunList.add(Math.abs(info - X));
                sabunAtaiList.add(info);
            }
            Object[] sabun = sabunList.toArray();
            Object[] sabunAtai = sabunAtaiList.toArray();


//            if (sabunList.size() > 0) {
                int intMin = (int) sabun[0];
                int minIndex = 0;
                for (int i = 1; i < sabun.length; i++) {

                    if (intMin > (int) sabun[i]) {
                        intMin = (int) sabun[i];
                        minIndex = i;
                    }
                }
                System.out.println(sabunAtai[minIndex]);
//            } else {
//
//                System.out.println(X);
//            }

        } else {

            System.out.println(X);
        } N != 0 N 0 {
            int[] suuretu = new int[N];
            for (int i = 0; i < N; i++) {
                suuretu[i] = scanner.nextInt();
            }
            Arrays.sort(suuretu);
//            System.out.println("  " +suuretu[N - 1] + " " + suuretu[0]);

            int[] junban = new int[suuretu[N - 1] - suuretu[0] + 3];
            int index = 0;
            for (int i = suuretu[0] - 1; i <= suuretu[N - 1] + 1; i++) {
                junban[index] = i;
//                System.out.println("  " + i);
                index++;
            }

            List<Integer> suuretuList = toList(suuretu);
            List<Integer> junbanList = toList(junban);
            junbanList.removeAll(suuretuList);
            List<Integer> sabunList = new ArrayList<>();
            List<Integer> sabunAtaiList = new ArrayList<>();
            for (Integer info : junbanList) {
//                System.out.println(info);
                sabunList.add(Math.abs(info - X));
                sabunAtaiList.add(info);
            }
            Object[] sabun = sabunList.toArray();
            Object[] sabunAtai = sabunAtaiList.toArray();


//            if (sabunList.size() > 0) {
                int intMin = (int) sabun[0];
                int minIndex = 0;
                for (int i = 1; i < sabun.length; i++) {

                    if (intMin > (int) sabun[i]) {
                        intMin = (int) sabun[i];
                        minIndex = i;
                    }
                }
                System.out.println(sabunAtai[minIndex]);
//            } else {
//
//                System.out.println(X);
//            }

        } int[] suuretu = new int[N]; suuretu new int[N] N for (int i = 0; i < N; i++) {
                suuretu[i] = scanner.nextInt();
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                suuretu[i] = scanner.nextInt();
            } {
                suuretu[i] = scanner.nextInt();
            } suuretu[i] = scanner.nextInt() suuretu[i] suuretu i scanner.nextInt() scanner.nextInt scanner Arrays.sort(suuretu) Arrays.sort Arrays suuretu int[] junban = new int[suuretu[N - 1] - suuretu[0] + 3]; junban new int[suuretu[N - 1] - suuretu[0] + 3] suuretu[N - 1] - suuretu[0] + 3 suuretu[N - 1] - suuretu[0] suuretu[N - 1] suuretu N - 1 N 1 suuretu[0] suuretu 0 3 int index = 0; index 0 for (int i = suuretu[0] - 1; i <= suuretu[N - 1] + 1; i++) {
                junban[index] = i;
//                System.out.println("  " + i);
                index++;
            } int i = suuretu[0] - 1; int i = suuretu[0] - 1; i suuretu[0] - 1 suuretu[0] suuretu 0 1 i <= suuretu[N - 1] + 1 i suuretu[N - 1] + 1 suuretu[N - 1] suuretu N - 1 N 1 1 i++ i++ i {
                junban[index] = i;
//                System.out.println("  " + i);
                index++;
            } {
                junban[index] = i;
//                System.out.println("  " + i);
                index++;
            } junban[index] = i junban[index] junban index i index++ index List<Integer> suuretuList = toList(suuretu); suuretuList toList(suuretu) toList suuretu List<Integer> junbanList = toList(junban); junbanList toList(junban) toList junban junbanList.removeAll(suuretuList) junbanList.removeAll junbanList suuretuList List<Integer> sabunList = new ArrayList<>(); sabunList new ArrayList<>() List<Integer> sabunAtaiList = new ArrayList<>(); sabunAtaiList new ArrayList<>() for (Integer info : junbanList) {
//                System.out.println(info);
                sabunList.add(Math.abs(info - X));
                sabunAtaiList.add(info);
            } Integer info junbanList {
//                System.out.println(info);
                sabunList.add(Math.abs(info - X));
                sabunAtaiList.add(info);
            } {
//                System.out.println(info);
                sabunList.add(Math.abs(info - X));
                sabunAtaiList.add(info);
            } sabunList.add(Math.abs(info - X)) sabunList.add sabunList Math.abs(info - X) Math.abs Math info - X info X sabunAtaiList.add(info) sabunAtaiList.add sabunAtaiList info Object[] sabun = sabunList.toArray(); sabun sabunList.toArray() sabunList.toArray sabunList Object[] sabunAtai = sabunAtaiList.toArray(); sabunAtai sabunAtaiList.toArray() sabunAtaiList.toArray sabunAtaiList int intMin = (int) sabun[0]; intMin (int) sabun[0] sabun 0 int minIndex = 0; minIndex 0 for (int i = 1; i < sabun.length; i++) {

                    if (intMin > (int) sabun[i]) {
                        intMin = (int) sabun[i];
                        minIndex = i;
                    }
                } int i = 1; int i = 1; i 1 i < sabun.length i sabun.length sabun sabun.length i++ i++ i {

                    if (intMin > (int) sabun[i]) {
                        intMin = (int) sabun[i];
                        minIndex = i;
                    }
                } {

                    if (intMin > (int) sabun[i]) {
                        intMin = (int) sabun[i];
                        minIndex = i;
                    }
                } if (intMin > (int) sabun[i]) {
                        intMin = (int) sabun[i];
                        minIndex = i;
                    } intMin > (int) sabun[i] intMin (int) sabun[i] sabun i {
                        intMin = (int) sabun[i];
                        minIndex = i;
                    } intMin = (int) sabun[i] intMin (int) sabun[i] sabun i minIndex = i minIndex i System.out.println(sabunAtai[minIndex]) System.out.println System.out System System.out sabunAtai[minIndex] sabunAtai minIndex {

            System.out.println(X);
        } System.out.println(X) System.out.println System.out System System.out X String[] args args public static ArrayList<Integer> toList(int[] arr){
        // int[] -> ArrayList<Integer>
        ArrayList<Integer> list = new ArrayList<Integer>();
        for (int t : arr) list.add(t);
        return list;
    } toList {
        // int[] -> ArrayList<Integer>
        ArrayList<Integer> list = new ArrayList<Integer>();
        for (int t : arr) list.add(t);
        return list;
    } ArrayList<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for (int t : arr) list.add(t); int t arr list.add(t); list.add(t) list.add list t return list; list int[] arr arr public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = 0;
        int N = 0;
        X = scanner.nextInt();
        N = scanner.nextInt();
        if (N != 0) {
            int[] suuretu = new int[N];
            for (int i = 0; i < N; i++) {
                suuretu[i] = scanner.nextInt();
            }
            Arrays.sort(suuretu);
//            System.out.println("  " +suuretu[N - 1] + " " + suuretu[0]);

            int[] junban = new int[suuretu[N - 1] - suuretu[0] + 3];
            int index = 0;
            for (int i = suuretu[0] - 1; i <= suuretu[N - 1] + 1; i++) {
                junban[index] = i;
//                System.out.println("  " + i);
                index++;
            }

            List<Integer> suuretuList = toList(suuretu);
            List<Integer> junbanList = toList(junban);
            junbanList.removeAll(suuretuList);
            List<Integer> sabunList = new ArrayList<>();
            List<Integer> sabunAtaiList = new ArrayList<>();
            for (Integer info : junbanList) {
//                System.out.println(info);
                sabunList.add(Math.abs(info - X));
                sabunAtaiList.add(info);
            }
            Object[] sabun = sabunList.toArray();
            Object[] sabunAtai = sabunAtaiList.toArray();


//            if (sabunList.size() > 0) {
                int intMin = (int) sabun[0];
                int minIndex = 0;
                for (int i = 1; i < sabun.length; i++) {

                    if (intMin > (int) sabun[i]) {
                        intMin = (int) sabun[i];
                        minIndex = i;
                    }
                }
                System.out.println(sabunAtai[minIndex]);
//            } else {
//
//                System.out.println(X);
//            }

        } else {

            System.out.println(X);
        }


    }

    public static ArrayList<Integer> toList(int[] arr){
        // int[] -> ArrayList<Integer>
        ArrayList<Integer> list = new ArrayList<Integer>();
        for (int t : arr) list.add(t);
        return list;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = 0;
        int N = 0;
        X = scanner.nextInt();
        N = scanner.nextInt();
        if (N != 0) {
            int[] suuretu = new int[N];
            for (int i = 0; i < N; i++) {
                suuretu[i] = scanner.nextInt();
            }
            Arrays.sort(suuretu);
//            System.out.println("  " +suuretu[N - 1] + " " + suuretu[0]);

            int[] junban = new int[suuretu[N - 1] - suuretu[0] + 3];
            int index = 0;
            for (int i = suuretu[0] - 1; i <= suuretu[N - 1] + 1; i++) {
                junban[index] = i;
//                System.out.println("  " + i);
                index++;
            }

            List<Integer> suuretuList = toList(suuretu);
            List<Integer> junbanList = toList(junban);
            junbanList.removeAll(suuretuList);
            List<Integer> sabunList = new ArrayList<>();
            List<Integer> sabunAtaiList = new ArrayList<>();
            for (Integer info : junbanList) {
//                System.out.println(info);
                sabunList.add(Math.abs(info - X));
                sabunAtaiList.add(info);
            }
            Object[] sabun = sabunList.toArray();
            Object[] sabunAtai = sabunAtaiList.toArray();


//            if (sabunList.size() > 0) {
                int intMin = (int) sabun[0];
                int minIndex = 0;
                for (int i = 1; i < sabun.length; i++) {

                    if (intMin > (int) sabun[i]) {
                        intMin = (int) sabun[i];
                        minIndex = i;
                    }
                }
                System.out.println(sabunAtai[minIndex]);
//            } else {
//
//                System.out.println(X);
//            }

        } else {

            System.out.println(X);
        }


    }

    public static ArrayList<Integer> toList(int[] arr){
        // int[] -> ArrayList<Integer>
        ArrayList<Integer> list = new ArrayList<Integer>();
        for (int t : arr) list.add(t);
        return list;
    }
} Main
import java.util.Arrays;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = 0;
        int N = 0;
        X = scanner.nextInt();
        N = scanner.nextInt();
        if (N != 0) {
            int[] suuretu = new int[N];
            for (int i = 0; i < N; i++) {
                suuretu[i] = scanner.nextInt();
            }
            Arrays.sort(suuretu);
//            System.out.println("  " +suuretu[N - 1] + " " + suuretu[0]);

            int[] junban = new int[suuretu[N - 1] - suuretu[0] + 3];
            int index = 0;
            for (int i = suuretu[0] - 1; i <= suuretu[N - 1] + 1; i++) {
                junban[index] = i;
//                System.out.println("  " + i);
                index++;
            }

            List<Integer> suuretuList = toList(suuretu);
            List<Integer> junbanList = toList(junban);
            junbanList.removeAll(suuretuList);
            List<Integer> sabunList = new ArrayList<>();
            List<Integer> sabunAtaiList = new ArrayList<>();
            for (Integer info : junbanList) {
//                System.out.println(info);
                sabunList.add(Math.abs(info - X));
                sabunAtaiList.add(info);
            }
            Object[] sabun = sabunList.toArray();
            Object[] sabunAtai = sabunAtaiList.toArray();


//            if (sabunList.size() > 0) {
                int intMin = (int) sabun[0];
                int minIndex = 0;
                for (int i = 1; i < sabun.length; i++) {

                    if (intMin > (int) sabun[i]) {
                        intMin = (int) sabun[i];
                        minIndex = i;
                    }
                }
                System.out.println(sabunAtai[minIndex]);
//            } else {
//
//                System.out.println(X);
//            }

        } else {

            System.out.println(X);
        }


    }

    public static ArrayList<Integer> toList(int[] arr){
        // int[] -> ArrayList<Integer>
        ArrayList<Integer> list = new ArrayList<Integer>();
        for (int t : arr) list.add(t);
        return list;
    }
}
