import java.util.ArrayList;
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<>();
    for (int i = 0; i < n; i++) {
      ps.add(sc.nextInt());
    }

    int max = Integer.MAX_VALUE;
    for (int i = 1; i <= n; i++) {
      int tmp = x + i;
      if (!ps.contains(tmp)) {
        max = tmp;
        break;
      }
    }
    int min = Integer.MAX_VALUE;
    for (int i = 0; i <= n; i++) {
      int tmp = x - i;
      if (!ps.contains(tmp)) {
        min = tmp;
        break;
      }
    }

    if (Math.abs(x - min) <= Math.abs(x - max)) {
      System.out.println(min);
    } else {
      System.out.println(max);
    }
  }
} import java.util.ArrayList; ArrayList 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<>();
    for (int i = 0; i < n; i++) {
      ps.add(sc.nextInt());
    }

    int max = Integer.MAX_VALUE;
    for (int i = 1; i <= n; i++) {
      int tmp = x + i;
      if (!ps.contains(tmp)) {
        max = tmp;
        break;
      }
    }
    int min = Integer.MAX_VALUE;
    for (int i = 0; i <= n; i++) {
      int tmp = x - i;
      if (!ps.contains(tmp)) {
        min = tmp;
        break;
      }
    }

    if (Math.abs(x - min) <= Math.abs(x - max)) {
      System.out.println(min);
    } else {
      System.out.println(max);
    }
  }
} 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<>();
    for (int i = 0; i < n; i++) {
      ps.add(sc.nextInt());
    }

    int max = Integer.MAX_VALUE;
    for (int i = 1; i <= n; i++) {
      int tmp = x + i;
      if (!ps.contains(tmp)) {
        max = tmp;
        break;
      }
    }
    int min = Integer.MAX_VALUE;
    for (int i = 0; i <= n; i++) {
      int tmp = x - i;
      if (!ps.contains(tmp)) {
        min = tmp;
        break;
      }
    }

    if (Math.abs(x - min) <= Math.abs(x - max)) {
      System.out.println(min);
    } else {
      System.out.println(max);
    }
  } 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<>();
    for (int i = 0; i < n; i++) {
      ps.add(sc.nextInt());
    }

    int max = Integer.MAX_VALUE;
    for (int i = 1; i <= n; i++) {
      int tmp = x + i;
      if (!ps.contains(tmp)) {
        max = tmp;
        break;
      }
    }
    int min = Integer.MAX_VALUE;
    for (int i = 0; i <= n; i++) {
      int tmp = x - i;
      if (!ps.contains(tmp)) {
        min = tmp;
        break;
      }
    }

    if (Math.abs(x - min) <= Math.abs(x - max)) {
      System.out.println(min);
    } else {
      System.out.println(max);
    }
  } 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<>(); ps new ArrayList<>() 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 int max = Integer.MAX_VALUE; max Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 1; i <= n; i++) {
      int tmp = x + i;
      if (!ps.contains(tmp)) {
        max = tmp;
        break;
      }
    } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
      int tmp = x + i;
      if (!ps.contains(tmp)) {
        max = tmp;
        break;
      }
    } {
      int tmp = x + i;
      if (!ps.contains(tmp)) {
        max = tmp;
        break;
      }
    } int tmp = x + i; tmp x + i x i if (!ps.contains(tmp)) {
        max = tmp;
        break;
      } !ps.contains(tmp) ps.contains(tmp) ps.contains ps tmp {
        max = tmp;
        break;
      } max = tmp max tmp break; int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 0; i <= n; i++) {
      int tmp = x - i;
      if (!ps.contains(tmp)) {
        min = tmp;
        break;
      }
    } int i = 0; int i = 0; i 0 i <= n i n i++ i++ i {
      int tmp = x - i;
      if (!ps.contains(tmp)) {
        min = tmp;
        break;
      }
    } {
      int tmp = x - i;
      if (!ps.contains(tmp)) {
        min = tmp;
        break;
      }
    } int tmp = x - i; tmp x - i x i if (!ps.contains(tmp)) {
        min = tmp;
        break;
      } !ps.contains(tmp) ps.contains(tmp) ps.contains ps tmp {
        min = tmp;
        break;
      } min = tmp min tmp break; if (Math.abs(x - min) <= Math.abs(x - max)) {
      System.out.println(min);
    } else {
      System.out.println(max);
    } Math.abs(x - min) <= Math.abs(x - max) Math.abs(x - min) Math.abs Math x - min x min Math.abs(x - max) Math.abs Math x - max x max {
      System.out.println(min);
    } System.out.println(min) System.out.println System.out System System.out min {
      System.out.println(max);
    } System.out.println(max) System.out.println System.out System System.out max 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<>();
    for (int i = 0; i < n; i++) {
      ps.add(sc.nextInt());
    }

    int max = Integer.MAX_VALUE;
    for (int i = 1; i <= n; i++) {
      int tmp = x + i;
      if (!ps.contains(tmp)) {
        max = tmp;
        break;
      }
    }
    int min = Integer.MAX_VALUE;
    for (int i = 0; i <= n; i++) {
      int tmp = x - i;
      if (!ps.contains(tmp)) {
        min = tmp;
        break;
      }
    }

    if (Math.abs(x - min) <= Math.abs(x - max)) {
      System.out.println(min);
    } else {
      System.out.println(max);
    }
  }
} 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<>();
    for (int i = 0; i < n; i++) {
      ps.add(sc.nextInt());
    }

    int max = Integer.MAX_VALUE;
    for (int i = 1; i <= n; i++) {
      int tmp = x + i;
      if (!ps.contains(tmp)) {
        max = tmp;
        break;
      }
    }
    int min = Integer.MAX_VALUE;
    for (int i = 0; i <= n; i++) {
      int tmp = x - i;
      if (!ps.contains(tmp)) {
        min = tmp;
        break;
      }
    }

    if (Math.abs(x - min) <= Math.abs(x - max)) {
      System.out.println(min);
    } else {
      System.out.println(max);
    }
  }
} Main
import java.util.ArrayList;
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<>();
    for (int i = 0; i < n; i++) {
      ps.add(sc.nextInt());
    }

    int max = Integer.MAX_VALUE;
    for (int i = 1; i <= n; i++) {
      int tmp = x + i;
      if (!ps.contains(tmp)) {
        max = tmp;
        break;
      }
    }
    int min = Integer.MAX_VALUE;
    for (int i = 0; i <= n; i++) {
      int tmp = x - i;
      if (!ps.contains(tmp)) {
        min = tmp;
        break;
      }
    }

    if (Math.abs(x - min) <= Math.abs(x - max)) {
      System.out.println(min);
    } else {
      System.out.println(max);
    }
  }
}
