import 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();
        int[] v = new int[102];

        if (n == 0) {
            System.out.println(x);
            return;
        }

        for (int i = 0; i < n; i++) {
            int p = sc.nextInt();
            v[p] = 1;
        }

        int left = 0, right = 0, ans_le = 0, ans_ri = 0;
        for (int i = x; i < v.length; i++) {
            if (v[i] == 0) {
                right = i - x;
                ans_ri = i;
                break;
            }
        }

        for (int i = x; i >= 0; i--) {
            if (v[i] == 0) {
                left = x - i;
                ans_le = i;
                break;
            }
        }

        if (left > right) {
            System.out.println(ans_ri);
        } else {
            System.out.println(ans_le);
        }
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] v = new int[102];

        if (n == 0) {
            System.out.println(x);
            return;
        }

        for (int i = 0; i < n; i++) {
            int p = sc.nextInt();
            v[p] = 1;
        }

        int left = 0, right = 0, ans_le = 0, ans_ri = 0;
        for (int i = x; i < v.length; i++) {
            if (v[i] == 0) {
                right = i - x;
                ans_ri = i;
                break;
            }
        }

        for (int i = x; i >= 0; i--) {
            if (v[i] == 0) {
                left = x - i;
                ans_le = i;
                break;
            }
        }

        if (left > right) {
            System.out.println(ans_ri);
        } else {
            System.out.println(ans_le);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] v = new int[102];

        if (n == 0) {
            System.out.println(x);
            return;
        }

        for (int i = 0; i < n; i++) {
            int p = sc.nextInt();
            v[p] = 1;
        }

        int left = 0, right = 0, ans_le = 0, ans_ri = 0;
        for (int i = x; i < v.length; i++) {
            if (v[i] == 0) {
                right = i - x;
                ans_ri = i;
                break;
            }
        }

        for (int i = x; i >= 0; i--) {
            if (v[i] == 0) {
                left = x - i;
                ans_le = i;
                break;
            }
        }

        if (left > right) {
            System.out.println(ans_ri);
        } else {
            System.out.println(ans_le);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] v = new int[102];

        if (n == 0) {
            System.out.println(x);
            return;
        }

        for (int i = 0; i < n; i++) {
            int p = sc.nextInt();
            v[p] = 1;
        }

        int left = 0, right = 0, ans_le = 0, ans_ri = 0;
        for (int i = x; i < v.length; i++) {
            if (v[i] == 0) {
                right = i - x;
                ans_ri = i;
                break;
            }
        }

        for (int i = x; i >= 0; i--) {
            if (v[i] == 0) {
                left = x - i;
                ans_le = i;
                break;
            }
        }

        if (left > right) {
            System.out.println(ans_ri);
        } else {
            System.out.println(ans_le);
        }
    } 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 int[] v = new int[102]; v new int[102] 102 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; for (int i = 0; i < n; i++) {
            int p = sc.nextInt();
            v[p] = 1;
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int p = sc.nextInt();
            v[p] = 1;
        } {
            int p = sc.nextInt();
            v[p] = 1;
        } int p = sc.nextInt(); p sc.nextInt() sc.nextInt sc v[p] = 1 v[p] v p 1 int left = 0 left 0 right = 0 right 0 ans_le = 0 ans_le 0 ans_ri = 0; ans_ri 0 for (int i = x; i < v.length; i++) {
            if (v[i] == 0) {
                right = i - x;
                ans_ri = i;
                break;
            }
        } int i = x; int i = x; i x i < v.length i v.length v v.length i++ i++ i {
            if (v[i] == 0) {
                right = i - x;
                ans_ri = i;
                break;
            }
        } {
            if (v[i] == 0) {
                right = i - x;
                ans_ri = i;
                break;
            }
        } if (v[i] == 0) {
                right = i - x;
                ans_ri = i;
                break;
            } v[i] == 0 v[i] v i 0 {
                right = i - x;
                ans_ri = i;
                break;
            } right = i - x right i - x i x ans_ri = i ans_ri i break; for (int i = x; i >= 0; i--) {
            if (v[i] == 0) {
                left = x - i;
                ans_le = i;
                break;
            }
        } int i = x; int i = x; i x i >= 0 i 0 i-- i-- i {
            if (v[i] == 0) {
                left = x - i;
                ans_le = i;
                break;
            }
        } {
            if (v[i] == 0) {
                left = x - i;
                ans_le = i;
                break;
            }
        } if (v[i] == 0) {
                left = x - i;
                ans_le = i;
                break;
            } v[i] == 0 v[i] v i 0 {
                left = x - i;
                ans_le = i;
                break;
            } left = x - i left x - i x i ans_le = i ans_le i break; if (left > right) {
            System.out.println(ans_ri);
        } else {
            System.out.println(ans_le);
        } left > right left right {
            System.out.println(ans_ri);
        } System.out.println(ans_ri) System.out.println System.out System System.out ans_ri {
            System.out.println(ans_le);
        } System.out.println(ans_le) System.out.println System.out System System.out ans_le 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();
        int[] v = new int[102];

        if (n == 0) {
            System.out.println(x);
            return;
        }

        for (int i = 0; i < n; i++) {
            int p = sc.nextInt();
            v[p] = 1;
        }

        int left = 0, right = 0, ans_le = 0, ans_ri = 0;
        for (int i = x; i < v.length; i++) {
            if (v[i] == 0) {
                right = i - x;
                ans_ri = i;
                break;
            }
        }

        for (int i = x; i >= 0; i--) {
            if (v[i] == 0) {
                left = x - i;
                ans_le = i;
                break;
            }
        }

        if (left > right) {
            System.out.println(ans_ri);
        } else {
            System.out.println(ans_le);
        }
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] v = new int[102];

        if (n == 0) {
            System.out.println(x);
            return;
        }

        for (int i = 0; i < n; i++) {
            int p = sc.nextInt();
            v[p] = 1;
        }

        int left = 0, right = 0, ans_le = 0, ans_ri = 0;
        for (int i = x; i < v.length; i++) {
            if (v[i] == 0) {
                right = i - x;
                ans_ri = i;
                break;
            }
        }

        for (int i = x; i >= 0; i--) {
            if (v[i] == 0) {
                left = x - i;
                ans_le = i;
                break;
            }
        }

        if (left > right) {
            System.out.println(ans_ri);
        } else {
            System.out.println(ans_le);
        }
    }
} Main
import 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();
        int[] v = new int[102];

        if (n == 0) {
            System.out.println(x);
            return;
        }

        for (int i = 0; i < n; i++) {
            int p = sc.nextInt();
            v[p] = 1;
        }

        int left = 0, right = 0, ans_le = 0, ans_ri = 0;
        for (int i = x; i < v.length; i++) {
            if (v[i] == 0) {
                right = i - x;
                ans_ri = i;
                break;
            }
        }

        for (int i = x; i >= 0; i--) {
            if (v[i] == 0) {
                left = x - i;
                ans_le = i;
                break;
            }
        }

        if (left > right) {
            System.out.println(ans_ri);
        } else {
            System.out.println(ans_le);
        }
    }
}