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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        if (N == 0) {
            System.out.println(X);
            return;
        }
        List<Integer> ps = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            ps.add(sc.nextInt());
        }
        Collections.sort(ps);

        int min = Integer.MAX_VALUE;
        int ans = -1;

        int st = ps.get(0) - 1;
        st = X < st ? X : st;
        int en = ps.get(ps.size() - 1) + 1;
        en = en < X ? X : en;
        for (int i = st; i <= en; i++) {
            if (!ps.contains(i)) {
                int res = Math.abs(X - i);
                if (res < min) {
                    min = res;
                    ans = i;
                }
            }
        }
        System.out.println(ans);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        if (N == 0) {
            System.out.println(X);
            return;
        }
        List<Integer> ps = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            ps.add(sc.nextInt());
        }
        Collections.sort(ps);

        int min = Integer.MAX_VALUE;
        int ans = -1;

        int st = ps.get(0) - 1;
        st = X < st ? X : st;
        int en = ps.get(ps.size() - 1) + 1;
        en = en < X ? X : en;
        for (int i = st; i <= en; i++) {
            if (!ps.contains(i)) {
                int res = Math.abs(X - i);
                if (res < min) {
                    min = res;
                    ans = i;
                }
            }
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        if (N == 0) {
            System.out.println(X);
            return;
        }
        List<Integer> ps = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            ps.add(sc.nextInt());
        }
        Collections.sort(ps);

        int min = Integer.MAX_VALUE;
        int ans = -1;

        int st = ps.get(0) - 1;
        st = X < st ? X : st;
        int en = ps.get(ps.size() - 1) + 1;
        en = en < X ? X : en;
        for (int i = st; i <= en; i++) {
            if (!ps.contains(i)) {
                int res = Math.abs(X - i);
                if (res < min) {
                    min = res;
                    ans = i;
                }
            }
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        if (N == 0) {
            System.out.println(X);
            return;
        }
        List<Integer> ps = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            ps.add(sc.nextInt());
        }
        Collections.sort(ps);

        int min = Integer.MAX_VALUE;
        int ans = -1;

        int st = ps.get(0) - 1;
        st = X < st ? X : st;
        int en = ps.get(ps.size() - 1) + 1;
        en = en < X ? X : en;
        for (int i = st; i <= en; i++) {
            if (!ps.contains(i)) {
                int res = Math.abs(X - i);
                if (res < min) {
                    min = res;
                    ans = i;
                }
            }
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc if (N == 0) {
            System.out.println(X);
            return;
        } N == 0 N 0 {
            System.out.println(X);
            return;
        } System.out.println(X) System.out.println System.out System System.out X return; List<Integer> ps = new ArrayList<Integer>(); ps new ArrayList<Integer>() for (int i = 0; i < N; i++) {
            ps.add(sc.nextInt());
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            ps.add(sc.nextInt());
        } {
            ps.add(sc.nextInt());
        } ps.add(sc.nextInt()) ps.add ps sc.nextInt() sc.nextInt sc Collections.sort(ps) Collections.sort Collections ps int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE int ans = -1; ans -1 1 int st = ps.get(0) - 1; st ps.get(0) - 1 ps.get(0) ps.get ps 0 1 st = X < st ? X : st st X < st ? X : st X < st X st X st int en = ps.get(ps.size() - 1) + 1; en ps.get(ps.size() - 1) + 1 ps.get(ps.size() - 1) ps.get ps ps.size() - 1 ps.size() ps.size ps 1 1 en = en < X ? X : en en en < X ? X : en en < X en X X en for (int i = st; i <= en; i++) {
            if (!ps.contains(i)) {
                int res = Math.abs(X - i);
                if (res < min) {
                    min = res;
                    ans = i;
                }
            }
        } int i = st; int i = st; i st i <= en i en i++ i++ i {
            if (!ps.contains(i)) {
                int res = Math.abs(X - i);
                if (res < min) {
                    min = res;
                    ans = i;
                }
            }
        } {
            if (!ps.contains(i)) {
                int res = Math.abs(X - i);
                if (res < min) {
                    min = res;
                    ans = i;
                }
            }
        } if (!ps.contains(i)) {
                int res = Math.abs(X - i);
                if (res < min) {
                    min = res;
                    ans = i;
                }
            } !ps.contains(i) ps.contains(i) ps.contains ps i {
                int res = Math.abs(X - i);
                if (res < min) {
                    min = res;
                    ans = i;
                }
            } int res = Math.abs(X - i); res Math.abs(X - i) Math.abs Math X - i X i if (res < min) {
                    min = res;
                    ans = i;
                } res < min res min {
                    min = res;
                    ans = i;
                } min = res min res ans = i ans i 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 sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        if (N == 0) {
            System.out.println(X);
            return;
        }
        List<Integer> ps = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            ps.add(sc.nextInt());
        }
        Collections.sort(ps);

        int min = Integer.MAX_VALUE;
        int ans = -1;

        int st = ps.get(0) - 1;
        st = X < st ? X : st;
        int en = ps.get(ps.size() - 1) + 1;
        en = en < X ? X : en;
        for (int i = st; i <= en; i++) {
            if (!ps.contains(i)) {
                int res = Math.abs(X - i);
                if (res < min) {
                    min = res;
                    ans = i;
                }
            }
        }
        System.out.println(ans);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        if (N == 0) {
            System.out.println(X);
            return;
        }
        List<Integer> ps = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            ps.add(sc.nextInt());
        }
        Collections.sort(ps);

        int min = Integer.MAX_VALUE;
        int ans = -1;

        int st = ps.get(0) - 1;
        st = X < st ? X : st;
        int en = ps.get(ps.size() - 1) + 1;
        en = en < X ? X : en;
        for (int i = st; i <= en; i++) {
            if (!ps.contains(i)) {
                int res = Math.abs(X - i);
                if (res < min) {
                    min = res;
                    ans = i;
                }
            }
        }
        System.out.println(ans);
    }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        if (N == 0) {
            System.out.println(X);
            return;
        }
        List<Integer> ps = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            ps.add(sc.nextInt());
        }
        Collections.sort(ps);

        int min = Integer.MAX_VALUE;
        int ans = -1;

        int st = ps.get(0) - 1;
        st = X < st ? X : st;
        int en = ps.get(ps.size() - 1) + 1;
        en = en < X ? X : en;
        for (int i = st; i <= en; i++) {
            if (!ps.contains(i)) {
                int res = Math.abs(X - i);
                if (res < min) {
                    min = res;
                    ans = i;
                }
            }
        }
        System.out.println(ans);
    }
}