import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws Exception {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    // Your code here!
    Scanner scan = new Scanner(is);
    int X = scan.nextInt();
    int N = scan.nextInt();
    HashSet<Integer> set = new HashSet<>();
    for(int i = 0 ; i < N; i++) {
      set.add(scan.nextInt());
    }

    if(!set.contains(X)) {
      os.println(X);
      return;
    }

    int diff = 1;
    while(true) {
      if(!set.contains(X-diff)) {
        os.println(X-diff);
        return;
      }
      if(!set.contains(X+diff)) {
        os.println(X+diff);
        return;
      }
      diff++;
    }
  }
} import java.io.InputStream; InputStream java.io import java.io.PrintStream; PrintStream java.io import java.math.BigDecimal; BigDecimal java.math import java.util.HashMap; HashMap java.util import java.util.HashSet; HashSet java.util import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) throws Exception {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    // Your code here!
    Scanner scan = new Scanner(is);
    int X = scan.nextInt();
    int N = scan.nextInt();
    HashSet<Integer> set = new HashSet<>();
    for(int i = 0 ; i < N; i++) {
      set.add(scan.nextInt());
    }

    if(!set.contains(X)) {
      os.println(X);
      return;
    }

    int diff = 1;
    while(true) {
      if(!set.contains(X-diff)) {
        os.println(X-diff);
        return;
      }
      if(!set.contains(X+diff)) {
        os.println(X+diff);
        return;
      }
      diff++;
    }
  }
} Main public static void main(String[] args) throws Exception {
    solve(System.in, System.out);
  } main {
    solve(System.in, System.out);
  } solve(System.in, System.out) solve System.in System System.in System.out System System.out String[] args args static void solve(InputStream is, PrintStream os) {
    // Your code here!
    Scanner scan = new Scanner(is);
    int X = scan.nextInt();
    int N = scan.nextInt();
    HashSet<Integer> set = new HashSet<>();
    for(int i = 0 ; i < N; i++) {
      set.add(scan.nextInt());
    }

    if(!set.contains(X)) {
      os.println(X);
      return;
    }

    int diff = 1;
    while(true) {
      if(!set.contains(X-diff)) {
        os.println(X-diff);
        return;
      }
      if(!set.contains(X+diff)) {
        os.println(X+diff);
        return;
      }
      diff++;
    }
  } solve {
    // Your code here!
    Scanner scan = new Scanner(is);
    int X = scan.nextInt();
    int N = scan.nextInt();
    HashSet<Integer> set = new HashSet<>();
    for(int i = 0 ; i < N; i++) {
      set.add(scan.nextInt());
    }

    if(!set.contains(X)) {
      os.println(X);
      return;
    }

    int diff = 1;
    while(true) {
      if(!set.contains(X-diff)) {
        os.println(X-diff);
        return;
      }
      if(!set.contains(X+diff)) {
        os.println(X+diff);
        return;
      }
      diff++;
    }
  } Scanner scan = new Scanner(is); scan new Scanner(is) int X = scan.nextInt(); X scan.nextInt() scan.nextInt scan int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan HashSet<Integer> set = new HashSet<>(); set new HashSet<>() for(int i = 0 ; i < N; i++) {
      set.add(scan.nextInt());
    } int i = 0 ; int i = 0 ; i 0 i < N i N i++ i++ i {
      set.add(scan.nextInt());
    } {
      set.add(scan.nextInt());
    } set.add(scan.nextInt()) set.add set scan.nextInt() scan.nextInt scan if(!set.contains(X)) {
      os.println(X);
      return;
    } !set.contains(X) set.contains(X) set.contains set X {
      os.println(X);
      return;
    } os.println(X) os.println os X return; int diff = 1; diff 1 while(true) {
      if(!set.contains(X-diff)) {
        os.println(X-diff);
        return;
      }
      if(!set.contains(X+diff)) {
        os.println(X+diff);
        return;
      }
      diff++;
    } true {
      if(!set.contains(X-diff)) {
        os.println(X-diff);
        return;
      }
      if(!set.contains(X+diff)) {
        os.println(X+diff);
        return;
      }
      diff++;
    } if(!set.contains(X-diff)) {
        os.println(X-diff);
        return;
      } !set.contains(X-diff) set.contains(X-diff) set.contains set X-diff X diff {
        os.println(X-diff);
        return;
      } os.println(X-diff) os.println os X-diff X diff return; if(!set.contains(X+diff)) {
        os.println(X+diff);
        return;
      } !set.contains(X+diff) set.contains(X+diff) set.contains set X+diff X diff {
        os.println(X+diff);
        return;
      } os.println(X+diff) os.println os X+diff X diff return; diff++ diff InputStream is is PrintStream os os public class Main {
  public static void main(String[] args) throws Exception {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    // Your code here!
    Scanner scan = new Scanner(is);
    int X = scan.nextInt();
    int N = scan.nextInt();
    HashSet<Integer> set = new HashSet<>();
    for(int i = 0 ; i < N; i++) {
      set.add(scan.nextInt());
    }

    if(!set.contains(X)) {
      os.println(X);
      return;
    }

    int diff = 1;
    while(true) {
      if(!set.contains(X-diff)) {
        os.println(X-diff);
        return;
      }
      if(!set.contains(X+diff)) {
        os.println(X+diff);
        return;
      }
      diff++;
    }
  }
} public class Main {
  public static void main(String[] args) throws Exception {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    // Your code here!
    Scanner scan = new Scanner(is);
    int X = scan.nextInt();
    int N = scan.nextInt();
    HashSet<Integer> set = new HashSet<>();
    for(int i = 0 ; i < N; i++) {
      set.add(scan.nextInt());
    }

    if(!set.contains(X)) {
      os.println(X);
      return;
    }

    int diff = 1;
    while(true) {
      if(!set.contains(X-diff)) {
        os.println(X-diff);
        return;
      }
      if(!set.contains(X+diff)) {
        os.println(X+diff);
        return;
      }
      diff++;
    }
  }
} Main
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws Exception {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    // Your code here!
    Scanner scan = new Scanner(is);
    int X = scan.nextInt();
    int N = scan.nextInt();
    HashSet<Integer> set = new HashSet<>();
    for(int i = 0 ; i < N; i++) {
      set.add(scan.nextInt());
    }

    if(!set.contains(X)) {
      os.println(X);
      return;
    }

    int diff = 1;
    while(true) {
      if(!set.contains(X-diff)) {
        os.println(X-diff);
        return;
      }
      if(!set.contains(X+diff)) {
        os.println(X+diff);
        return;
      }
      diff++;
    }
  }
}
