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

public class Main {
    public static void main(String[] args) {
        System.out.println(run());
    }

    private static ArrayList<Integer> nScan(Scanner sc, int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            al.add(sc.nextInt());
        }
        return al;
    }

    private static Object run() {
        try (Scanner sc = new Scanner(System.in);) {
            int x = sc.nextInt(), n = sc.nextInt(), result = 0;
            if (n == 0) {
                return x;
            }
            ArrayList<Integer> p = nScan(sc, n);
            for (int i = x;;i++) {
                if (!p.contains(i)) {
                    result = i;
                    break;
                }
            }
            for (int i = x;;i--) {
                if (!p.contains(i)) {
                    if (result - x >= x - i) {
                        result = i;
                    }
                    break;
                }
            }
            return result;
        }
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        System.out.println(run());
    }

    private static ArrayList<Integer> nScan(Scanner sc, int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            al.add(sc.nextInt());
        }
        return al;
    }

    private static Object run() {
        try (Scanner sc = new Scanner(System.in);) {
            int x = sc.nextInt(), n = sc.nextInt(), result = 0;
            if (n == 0) {
                return x;
            }
            ArrayList<Integer> p = nScan(sc, n);
            for (int i = x;;i++) {
                if (!p.contains(i)) {
                    result = i;
                    break;
                }
            }
            for (int i = x;;i--) {
                if (!p.contains(i)) {
                    if (result - x >= x - i) {
                        result = i;
                    }
                    break;
                }
            }
            return result;
        }
    }
} Main public static void main(String[] args) {
        System.out.println(run());
    } main {
        System.out.println(run());
    } System.out.println(run()) System.out.println System.out System System.out run() run String[] args args private static ArrayList<Integer> nScan(Scanner sc, int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            al.add(sc.nextInt());
        }
        return al;
    } nScan {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            al.add(sc.nextInt());
        }
        return al;
    } ArrayList<Integer> al = new ArrayList<>(); al new ArrayList<>() for (int i = 0; i < n; i++) {
            al.add(sc.nextInt());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            al.add(sc.nextInt());
        } {
            al.add(sc.nextInt());
        } al.add(sc.nextInt()) al.add al sc.nextInt() sc.nextInt sc return al; al Scanner sc sc int n n private static Object run() {
        try (Scanner sc = new Scanner(System.in);) {
            int x = sc.nextInt(), n = sc.nextInt(), result = 0;
            if (n == 0) {
                return x;
            }
            ArrayList<Integer> p = nScan(sc, n);
            for (int i = x;;i++) {
                if (!p.contains(i)) {
                    result = i;
                    break;
                }
            }
            for (int i = x;;i--) {
                if (!p.contains(i)) {
                    if (result - x >= x - i) {
                        result = i;
                    }
                    break;
                }
            }
            return result;
        }
    } run {
        try (Scanner sc = new Scanner(System.in);) {
            int x = sc.nextInt(), n = sc.nextInt(), result = 0;
            if (n == 0) {
                return x;
            }
            ArrayList<Integer> p = nScan(sc, n);
            for (int i = x;;i++) {
                if (!p.contains(i)) {
                    result = i;
                    break;
                }
            }
            for (int i = x;;i--) {
                if (!p.contains(i)) {
                    if (result - x >= x - i) {
                        result = i;
                    }
                    break;
                }
            }
            return result;
        }
    } try (Scanner sc = new Scanner(System.in);) {
            int x = sc.nextInt(), n = sc.nextInt(), result = 0;
            if (n == 0) {
                return x;
            }
            ArrayList<Integer> p = nScan(sc, n);
            for (int i = x;;i++) {
                if (!p.contains(i)) {
                    result = i;
                    break;
                }
            }
            for (int i = x;;i--) {
                if (!p.contains(i)) {
                    if (result - x >= x - i) {
                        result = i;
                    }
                    break;
                }
            }
            return result;
        } {
            int x = sc.nextInt(), n = sc.nextInt(), result = 0;
            if (n == 0) {
                return x;
            }
            ArrayList<Integer> p = nScan(sc, n);
            for (int i = x;;i++) {
                if (!p.contains(i)) {
                    result = i;
                    break;
                }
            }
            for (int i = x;;i--) {
                if (!p.contains(i)) {
                    if (result - x >= x - i) {
                        result = i;
                    }
                    break;
                }
            }
            return result;
        } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int x = sc.nextInt() x sc.nextInt() sc.nextInt sc n = sc.nextInt() n sc.nextInt() sc.nextInt sc result = 0; result 0 if (n == 0) {
                return x;
            } n == 0 n 0 {
                return x;
            } return x; x ArrayList<Integer> p = nScan(sc, n); p nScan(sc, n) nScan sc n for (int i = x;;i++) {
                if (!p.contains(i)) {
                    result = i;
                    break;
                }
            } int i = x; int i = x; i x i++ i++ i {
                if (!p.contains(i)) {
                    result = i;
                    break;
                }
            } {
                if (!p.contains(i)) {
                    result = i;
                    break;
                }
            } if (!p.contains(i)) {
                    result = i;
                    break;
                } !p.contains(i) p.contains(i) p.contains p i {
                    result = i;
                    break;
                } result = i result i break; for (int i = x;;i--) {
                if (!p.contains(i)) {
                    if (result - x >= x - i) {
                        result = i;
                    }
                    break;
                }
            } int i = x; int i = x; i x i-- i-- i {
                if (!p.contains(i)) {
                    if (result - x >= x - i) {
                        result = i;
                    }
                    break;
                }
            } {
                if (!p.contains(i)) {
                    if (result - x >= x - i) {
                        result = i;
                    }
                    break;
                }
            } if (!p.contains(i)) {
                    if (result - x >= x - i) {
                        result = i;
                    }
                    break;
                } !p.contains(i) p.contains(i) p.contains p i {
                    if (result - x >= x - i) {
                        result = i;
                    }
                    break;
                } if (result - x >= x - i) {
                        result = i;
                    } result - x >= x - i result - x result x x - i x i {
                        result = i;
                    } result = i result i break; return result; result public class Main {
    public static void main(String[] args) {
        System.out.println(run());
    }

    private static ArrayList<Integer> nScan(Scanner sc, int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            al.add(sc.nextInt());
        }
        return al;
    }

    private static Object run() {
        try (Scanner sc = new Scanner(System.in);) {
            int x = sc.nextInt(), n = sc.nextInt(), result = 0;
            if (n == 0) {
                return x;
            }
            ArrayList<Integer> p = nScan(sc, n);
            for (int i = x;;i++) {
                if (!p.contains(i)) {
                    result = i;
                    break;
                }
            }
            for (int i = x;;i--) {
                if (!p.contains(i)) {
                    if (result - x >= x - i) {
                        result = i;
                    }
                    break;
                }
            }
            return result;
        }
    }
} public class Main {
    public static void main(String[] args) {
        System.out.println(run());
    }

    private static ArrayList<Integer> nScan(Scanner sc, int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            al.add(sc.nextInt());
        }
        return al;
    }

    private static Object run() {
        try (Scanner sc = new Scanner(System.in);) {
            int x = sc.nextInt(), n = sc.nextInt(), result = 0;
            if (n == 0) {
                return x;
            }
            ArrayList<Integer> p = nScan(sc, n);
            for (int i = x;;i++) {
                if (!p.contains(i)) {
                    result = i;
                    break;
                }
            }
            for (int i = x;;i--) {
                if (!p.contains(i)) {
                    if (result - x >= x - i) {
                        result = i;
                    }
                    break;
                }
            }
            return result;
        }
    }
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        System.out.println(run());
    }

    private static ArrayList<Integer> nScan(Scanner sc, int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            al.add(sc.nextInt());
        }
        return al;
    }

    private static Object run() {
        try (Scanner sc = new Scanner(System.in);) {
            int x = sc.nextInt(), n = sc.nextInt(), result = 0;
            if (n == 0) {
                return x;
            }
            ArrayList<Integer> p = nScan(sc, n);
            for (int i = x;;i++) {
                if (!p.contains(i)) {
                    result = i;
                    break;
                }
            }
            for (int i = x;;i--) {
                if (!p.contains(i)) {
                    if (result - x >= x - i) {
                        result = i;
                    }
                    break;
                }
            }
            return result;
        }
    }
}