import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC170_c solver = new ABC170_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC170_c {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            int N = in.nextInt();
            int p[] = new int[N];
            int mas[] = new int[110];
            for (int i = 0; i < mas.length; i++) {
                mas[i] = Integer.MAX_VALUE;
            }
            for (int i = 0; i < N; i++) {
                p[i] = in.nextInt();
            }
            Arrays.sort(p);
            for (int i = 0; i < p.length; i++) {
                mas[p[i]] = p[i];
            }
            if (mas[X] == Integer.MAX_VALUE) {
                out.println(X);
                return;
            }
            int plus = 0;
            for (int i = X; i < mas.length; i++) {
                if (mas[i] == Integer.MAX_VALUE) {
                    plus = i;
                    break;
                }
            }
            int minus = 0;
            for (int i = X; i >= 0; i--) {
                if (mas[i] == Integer.MAX_VALUE) {
                    minus = i;
                    break;
                }
            }
            if (Math.abs(X - plus) >= Math.abs(X - minus)) {
                out.println(minus);
            } else {
                out.println(plus);
            }
        }

    }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC170_c solver = new ABC170_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC170_c {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            int N = in.nextInt();
            int p[] = new int[N];
            int mas[] = new int[110];
            for (int i = 0; i < mas.length; i++) {
                mas[i] = Integer.MAX_VALUE;
            }
            for (int i = 0; i < N; i++) {
                p[i] = in.nextInt();
            }
            Arrays.sort(p);
            for (int i = 0; i < p.length; i++) {
                mas[p[i]] = p[i];
            }
            if (mas[X] == Integer.MAX_VALUE) {
                out.println(X);
                return;
            }
            int plus = 0;
            for (int i = X; i < mas.length; i++) {
                if (mas[i] == Integer.MAX_VALUE) {
                    plus = i;
                    break;
                }
            }
            int minus = 0;
            for (int i = X; i >= 0; i--) {
                if (mas[i] == Integer.MAX_VALUE) {
                    minus = i;
                    break;
                }
            }
            if (Math.abs(X - plus) >= Math.abs(X - minus)) {
                out.println(minus);
            } else {
                out.println(plus);
            }
        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC170_c solver = new ABC170_c();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC170_c solver = new ABC170_c();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) ABC170_c solver = new ABC170_c(); solver new ABC170_c() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class ABC170_c {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            int N = in.nextInt();
            int p[] = new int[N];
            int mas[] = new int[110];
            for (int i = 0; i < mas.length; i++) {
                mas[i] = Integer.MAX_VALUE;
            }
            for (int i = 0; i < N; i++) {
                p[i] = in.nextInt();
            }
            Arrays.sort(p);
            for (int i = 0; i < p.length; i++) {
                mas[p[i]] = p[i];
            }
            if (mas[X] == Integer.MAX_VALUE) {
                out.println(X);
                return;
            }
            int plus = 0;
            for (int i = X; i < mas.length; i++) {
                if (mas[i] == Integer.MAX_VALUE) {
                    plus = i;
                    break;
                }
            }
            int minus = 0;
            for (int i = X; i >= 0; i--) {
                if (mas[i] == Integer.MAX_VALUE) {
                    minus = i;
                    break;
                }
            }
            if (Math.abs(X - plus) >= Math.abs(X - minus)) {
                out.println(minus);
            } else {
                out.println(plus);
            }
        }

    } ABC170_c public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            int N = in.nextInt();
            int p[] = new int[N];
            int mas[] = new int[110];
            for (int i = 0; i < mas.length; i++) {
                mas[i] = Integer.MAX_VALUE;
            }
            for (int i = 0; i < N; i++) {
                p[i] = in.nextInt();
            }
            Arrays.sort(p);
            for (int i = 0; i < p.length; i++) {
                mas[p[i]] = p[i];
            }
            if (mas[X] == Integer.MAX_VALUE) {
                out.println(X);
                return;
            }
            int plus = 0;
            for (int i = X; i < mas.length; i++) {
                if (mas[i] == Integer.MAX_VALUE) {
                    plus = i;
                    break;
                }
            }
            int minus = 0;
            for (int i = X; i >= 0; i--) {
                if (mas[i] == Integer.MAX_VALUE) {
                    minus = i;
                    break;
                }
            }
            if (Math.abs(X - plus) >= Math.abs(X - minus)) {
                out.println(minus);
            } else {
                out.println(plus);
            }
        } solve {
            int X = in.nextInt();
            int N = in.nextInt();
            int p[] = new int[N];
            int mas[] = new int[110];
            for (int i = 0; i < mas.length; i++) {
                mas[i] = Integer.MAX_VALUE;
            }
            for (int i = 0; i < N; i++) {
                p[i] = in.nextInt();
            }
            Arrays.sort(p);
            for (int i = 0; i < p.length; i++) {
                mas[p[i]] = p[i];
            }
            if (mas[X] == Integer.MAX_VALUE) {
                out.println(X);
                return;
            }
            int plus = 0;
            for (int i = X; i < mas.length; i++) {
                if (mas[i] == Integer.MAX_VALUE) {
                    plus = i;
                    break;
                }
            }
            int minus = 0;
            for (int i = X; i >= 0; i--) {
                if (mas[i] == Integer.MAX_VALUE) {
                    minus = i;
                    break;
                }
            }
            if (Math.abs(X - plus) >= Math.abs(X - minus)) {
                out.println(minus);
            } else {
                out.println(plus);
            }
        } int X = in.nextInt(); X in.nextInt() in.nextInt in int N = in.nextInt(); N in.nextInt() in.nextInt in int p[] = new int[N]; p new int[N] N int mas[] = new int[110]; mas new int[110] 110 for (int i = 0; i < mas.length; i++) {
                mas[i] = Integer.MAX_VALUE;
            } int i = 0; int i = 0; i 0 i < mas.length i mas.length mas mas.length i++ i++ i {
                mas[i] = Integer.MAX_VALUE;
            } {
                mas[i] = Integer.MAX_VALUE;
            } mas[i] = Integer.MAX_VALUE mas[i] mas i Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 0; i < N; i++) {
                p[i] = in.nextInt();
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                p[i] = in.nextInt();
            } {
                p[i] = in.nextInt();
            } p[i] = in.nextInt() p[i] p i in.nextInt() in.nextInt in Arrays.sort(p) Arrays.sort Arrays p for (int i = 0; i < p.length; i++) {
                mas[p[i]] = p[i];
            } int i = 0; int i = 0; i 0 i < p.length i p.length p p.length i++ i++ i {
                mas[p[i]] = p[i];
            } {
                mas[p[i]] = p[i];
            } mas[p[i]] = p[i] mas[p[i]] mas p[i] p i p[i] p i if (mas[X] == Integer.MAX_VALUE) {
                out.println(X);
                return;
            } mas[X] == Integer.MAX_VALUE mas[X] mas X Integer.MAX_VALUE Integer Integer.MAX_VALUE {
                out.println(X);
                return;
            } out.println(X) out.println out X return; int plus = 0; plus 0 for (int i = X; i < mas.length; i++) {
                if (mas[i] == Integer.MAX_VALUE) {
                    plus = i;
                    break;
                }
            } int i = X; int i = X; i X i < mas.length i mas.length mas mas.length i++ i++ i {
                if (mas[i] == Integer.MAX_VALUE) {
                    plus = i;
                    break;
                }
            } {
                if (mas[i] == Integer.MAX_VALUE) {
                    plus = i;
                    break;
                }
            } if (mas[i] == Integer.MAX_VALUE) {
                    plus = i;
                    break;
                } mas[i] == Integer.MAX_VALUE mas[i] mas i Integer.MAX_VALUE Integer Integer.MAX_VALUE {
                    plus = i;
                    break;
                } plus = i plus i break; int minus = 0; minus 0 for (int i = X; i >= 0; i--) {
                if (mas[i] == Integer.MAX_VALUE) {
                    minus = i;
                    break;
                }
            } int i = X; int i = X; i X i >= 0 i 0 i-- i-- i {
                if (mas[i] == Integer.MAX_VALUE) {
                    minus = i;
                    break;
                }
            } {
                if (mas[i] == Integer.MAX_VALUE) {
                    minus = i;
                    break;
                }
            } if (mas[i] == Integer.MAX_VALUE) {
                    minus = i;
                    break;
                } mas[i] == Integer.MAX_VALUE mas[i] mas i Integer.MAX_VALUE Integer Integer.MAX_VALUE {
                    minus = i;
                    break;
                } minus = i minus i break; if (Math.abs(X - plus) >= Math.abs(X - minus)) {
                out.println(minus);
            } else {
                out.println(plus);
            } Math.abs(X - plus) >= Math.abs(X - minus) Math.abs(X - plus) Math.abs Math X - plus X plus Math.abs(X - minus) Math.abs Math X - minus X minus {
                out.println(minus);
            } out.println(minus) out.println out minus {
                out.println(plus);
            } out.println(plus) out.println out plus int testNumber testNumber Scanner in in PrintWriter out out public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC170_c solver = new ABC170_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC170_c {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            int N = in.nextInt();
            int p[] = new int[N];
            int mas[] = new int[110];
            for (int i = 0; i < mas.length; i++) {
                mas[i] = Integer.MAX_VALUE;
            }
            for (int i = 0; i < N; i++) {
                p[i] = in.nextInt();
            }
            Arrays.sort(p);
            for (int i = 0; i < p.length; i++) {
                mas[p[i]] = p[i];
            }
            if (mas[X] == Integer.MAX_VALUE) {
                out.println(X);
                return;
            }
            int plus = 0;
            for (int i = X; i < mas.length; i++) {
                if (mas[i] == Integer.MAX_VALUE) {
                    plus = i;
                    break;
                }
            }
            int minus = 0;
            for (int i = X; i >= 0; i--) {
                if (mas[i] == Integer.MAX_VALUE) {
                    minus = i;
                    break;
                }
            }
            if (Math.abs(X - plus) >= Math.abs(X - minus)) {
                out.println(minus);
            } else {
                out.println(plus);
            }
        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC170_c solver = new ABC170_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC170_c {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            int N = in.nextInt();
            int p[] = new int[N];
            int mas[] = new int[110];
            for (int i = 0; i < mas.length; i++) {
                mas[i] = Integer.MAX_VALUE;
            }
            for (int i = 0; i < N; i++) {
                p[i] = in.nextInt();
            }
            Arrays.sort(p);
            for (int i = 0; i < p.length; i++) {
                mas[p[i]] = p[i];
            }
            if (mas[X] == Integer.MAX_VALUE) {
                out.println(X);
                return;
            }
            int plus = 0;
            for (int i = X; i < mas.length; i++) {
                if (mas[i] == Integer.MAX_VALUE) {
                    plus = i;
                    break;
                }
            }
            int minus = 0;
            for (int i = X; i >= 0; i--) {
                if (mas[i] == Integer.MAX_VALUE) {
                    minus = i;
                    break;
                }
            }
            if (Math.abs(X - plus) >= Math.abs(X - minus)) {
                out.println(minus);
            } else {
                out.println(plus);
            }
        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC170_c solver = new ABC170_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC170_c {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            int N = in.nextInt();
            int p[] = new int[N];
            int mas[] = new int[110];
            for (int i = 0; i < mas.length; i++) {
                mas[i] = Integer.MAX_VALUE;
            }
            for (int i = 0; i < N; i++) {
                p[i] = in.nextInt();
            }
            Arrays.sort(p);
            for (int i = 0; i < p.length; i++) {
                mas[p[i]] = p[i];
            }
            if (mas[X] == Integer.MAX_VALUE) {
                out.println(X);
                return;
            }
            int plus = 0;
            for (int i = X; i < mas.length; i++) {
                if (mas[i] == Integer.MAX_VALUE) {
                    plus = i;
                    break;
                }
            }
            int minus = 0;
            for (int i = X; i >= 0; i--) {
                if (mas[i] == Integer.MAX_VALUE) {
                    minus = i;
                    break;
                }
            }
            if (Math.abs(X - plus) >= Math.abs(X - minus)) {
                out.println(minus);
            } else {
                out.println(plus);
            }
        }

    }
}

