import java.util.*;
public class Main {
  public static void main(String... args) {
    Scanner input = new Scanner(System.in);
    
    int x = input.nextInt();
    int n = input.nextInt();
    
    Set<Integer> set = new HashSet<>();
    int[] a = new int[n];
    boolean notFound = true;
    for (int i = 0; i < n; i++) {
      set.add(input.nextInt());
    }

    int lower = x;
    int higher = x;
    
    while (set.contains(lower)) {
      lower--;
    }
    
    while (set.contains(higher)) {
      higher++;
    }
    
    System.out.println(x - lower <= higher - x ? lower : higher);
  }
} import java.util.*; util.* java public class Main {
  public static void main(String... args) {
    Scanner input = new Scanner(System.in);
    
    int x = input.nextInt();
    int n = input.nextInt();
    
    Set<Integer> set = new HashSet<>();
    int[] a = new int[n];
    boolean notFound = true;
    for (int i = 0; i < n; i++) {
      set.add(input.nextInt());
    }

    int lower = x;
    int higher = x;
    
    while (set.contains(lower)) {
      lower--;
    }
    
    while (set.contains(higher)) {
      higher++;
    }
    
    System.out.println(x - lower <= higher - x ? lower : higher);
  }
} Main public static void main(String... args) {
    Scanner input = new Scanner(System.in);
    
    int x = input.nextInt();
    int n = input.nextInt();
    
    Set<Integer> set = new HashSet<>();
    int[] a = new int[n];
    boolean notFound = true;
    for (int i = 0; i < n; i++) {
      set.add(input.nextInt());
    }

    int lower = x;
    int higher = x;
    
    while (set.contains(lower)) {
      lower--;
    }
    
    while (set.contains(higher)) {
      higher++;
    }
    
    System.out.println(x - lower <= higher - x ? lower : higher);
  } main {
    Scanner input = new Scanner(System.in);
    
    int x = input.nextInt();
    int n = input.nextInt();
    
    Set<Integer> set = new HashSet<>();
    int[] a = new int[n];
    boolean notFound = true;
    for (int i = 0; i < n; i++) {
      set.add(input.nextInt());
    }

    int lower = x;
    int higher = x;
    
    while (set.contains(lower)) {
      lower--;
    }
    
    while (set.contains(higher)) {
      higher++;
    }
    
    System.out.println(x - lower <= higher - x ? lower : higher);
  } Scanner input = new Scanner(System.in); input new Scanner(System.in) int x = input.nextInt(); x input.nextInt() input.nextInt input int n = input.nextInt(); n input.nextInt() input.nextInt input Set<Integer> set = new HashSet<>(); set new HashSet<>() int[] a = new int[n]; a new int[n] n boolean notFound = true; notFound true for (int i = 0; i < n; i++) {
      set.add(input.nextInt());
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      set.add(input.nextInt());
    } {
      set.add(input.nextInt());
    } set.add(input.nextInt()) set.add set input.nextInt() input.nextInt input int lower = x; lower x int higher = x; higher x while (set.contains(lower)) {
      lower--;
    } set.contains(lower) set.contains set lower {
      lower--;
    } lower-- lower while (set.contains(higher)) {
      higher++;
    } set.contains(higher) set.contains set higher {
      higher++;
    } higher++ higher System.out.println(x - lower <= higher - x ? lower : higher) System.out.println System.out System System.out x - lower <= higher - x ? lower : higher x - lower <= higher - x x - lower x lower higher - x higher x lower higher String... args args public class Main {
  public static void main(String... args) {
    Scanner input = new Scanner(System.in);
    
    int x = input.nextInt();
    int n = input.nextInt();
    
    Set<Integer> set = new HashSet<>();
    int[] a = new int[n];
    boolean notFound = true;
    for (int i = 0; i < n; i++) {
      set.add(input.nextInt());
    }

    int lower = x;
    int higher = x;
    
    while (set.contains(lower)) {
      lower--;
    }
    
    while (set.contains(higher)) {
      higher++;
    }
    
    System.out.println(x - lower <= higher - x ? lower : higher);
  }
} public class Main {
  public static void main(String... args) {
    Scanner input = new Scanner(System.in);
    
    int x = input.nextInt();
    int n = input.nextInt();
    
    Set<Integer> set = new HashSet<>();
    int[] a = new int[n];
    boolean notFound = true;
    for (int i = 0; i < n; i++) {
      set.add(input.nextInt());
    }

    int lower = x;
    int higher = x;
    
    while (set.contains(lower)) {
      lower--;
    }
    
    while (set.contains(higher)) {
      higher++;
    }
    
    System.out.println(x - lower <= higher - x ? lower : higher);
  }
} Main
import java.util.*;
public class Main {
  public static void main(String... args) {
    Scanner input = new Scanner(System.in);
    
    int x = input.nextInt();
    int n = input.nextInt();
    
    Set<Integer> set = new HashSet<>();
    int[] a = new int[n];
    boolean notFound = true;
    for (int i = 0; i < n; i++) {
      set.add(input.nextInt());
    }

    int lower = x;
    int higher = x;
    
    while (set.contains(lower)) {
      lower--;
    }
    
    while (set.contains(higher)) {
      higher++;
    }
    
    System.out.println(x - lower <= higher - x ? lower : higher);
  }
}