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;
    }
    int distance = 0;
    int answer = 0;
    List<Integer> list = new ArrayList();
    for(int i = 0; i < n; i++){
      list.add(sc.nextInt());
    }
    while(true){
      if(list.contains(x + distance)){
        if(distance < 0){
          distance = - distance;
        } else {
          distance = (distance + 1) * -1;
        }
      } else {
        answer = x + distance;
        break;
      }
    }
    System.out.println(answer);
  }
} 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;
    }
    int distance = 0;
    int answer = 0;
    List<Integer> list = new ArrayList();
    for(int i = 0; i < n; i++){
      list.add(sc.nextInt());
    }
    while(true){
      if(list.contains(x + distance)){
        if(distance < 0){
          distance = - distance;
        } else {
          distance = (distance + 1) * -1;
        }
      } else {
        answer = x + distance;
        break;
      }
    }
    System.out.println(answer);
  }
} 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;
    }
    int distance = 0;
    int answer = 0;
    List<Integer> list = new ArrayList();
    for(int i = 0; i < n; i++){
      list.add(sc.nextInt());
    }
    while(true){
      if(list.contains(x + distance)){
        if(distance < 0){
          distance = - distance;
        } else {
          distance = (distance + 1) * -1;
        }
      } else {
        answer = x + distance;
        break;
      }
    }
    System.out.println(answer);
  } main {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int n = sc.nextInt();
    if(n == 0){
      System.out.println(x);
      return;
    }
    int distance = 0;
    int answer = 0;
    List<Integer> list = new ArrayList();
    for(int i = 0; i < n; i++){
      list.add(sc.nextInt());
    }
    while(true){
      if(list.contains(x + distance)){
        if(distance < 0){
          distance = - distance;
        } else {
          distance = (distance + 1) * -1;
        }
      } else {
        answer = x + distance;
        break;
      }
    }
    System.out.println(answer);
  } 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; int distance = 0; distance 0 int answer = 0; answer 0 List<Integer> list = new ArrayList(); list new ArrayList() for(int i = 0; i < n; i++){
      list.add(sc.nextInt());
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      list.add(sc.nextInt());
    } {
      list.add(sc.nextInt());
    } list.add(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc while(true){
      if(list.contains(x + distance)){
        if(distance < 0){
          distance = - distance;
        } else {
          distance = (distance + 1) * -1;
        }
      } else {
        answer = x + distance;
        break;
      }
    } true {
      if(list.contains(x + distance)){
        if(distance < 0){
          distance = - distance;
        } else {
          distance = (distance + 1) * -1;
        }
      } else {
        answer = x + distance;
        break;
      }
    } if(list.contains(x + distance)){
        if(distance < 0){
          distance = - distance;
        } else {
          distance = (distance + 1) * -1;
        }
      } else {
        answer = x + distance;
        break;
      } list.contains(x + distance) list.contains list x + distance x distance {
        if(distance < 0){
          distance = - distance;
        } else {
          distance = (distance + 1) * -1;
        }
      } if(distance < 0){
          distance = - distance;
        } else {
          distance = (distance + 1) * -1;
        } distance < 0 distance 0 {
          distance = - distance;
        } distance = - distance distance - distance distance {
          distance = (distance + 1) * -1;
        } distance = (distance + 1) * -1 distance (distance + 1) * -1 (distance + 1) distance 1 -1 1 {
        answer = x + distance;
        break;
      } answer = x + distance answer x + distance x distance break; System.out.println(answer) System.out.println System.out System System.out answer 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;
    }
    int distance = 0;
    int answer = 0;
    List<Integer> list = new ArrayList();
    for(int i = 0; i < n; i++){
      list.add(sc.nextInt());
    }
    while(true){
      if(list.contains(x + distance)){
        if(distance < 0){
          distance = - distance;
        } else {
          distance = (distance + 1) * -1;
        }
      } else {
        answer = x + distance;
        break;
      }
    }
    System.out.println(answer);
  }
} 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;
    }
    int distance = 0;
    int answer = 0;
    List<Integer> list = new ArrayList();
    for(int i = 0; i < n; i++){
      list.add(sc.nextInt());
    }
    while(true){
      if(list.contains(x + distance)){
        if(distance < 0){
          distance = - distance;
        } else {
          distance = (distance + 1) * -1;
        }
      } else {
        answer = x + distance;
        break;
      }
    }
    System.out.println(answer);
  }
} 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;
    }
    int distance = 0;
    int answer = 0;
    List<Integer> list = new ArrayList();
    for(int i = 0; i < n; i++){
      list.add(sc.nextInt());
    }
    while(true){
      if(list.contains(x + distance)){
        if(distance < 0){
          distance = - distance;
        } else {
          distance = (distance + 1) * -1;
        }
      } else {
        answer = x + distance;
        break;
      }
    }
    System.out.println(answer);
  }
}