jiahuimbzuai/CoQuIR huggingface dataset:
//  [javascript]
(async () => {
    let input = '';
    for await (const chunk of process.stdin) input += chunk;
    const lines = input.split(/\n/);
    const [n, k] = lines.shift().split(/\s/).map(v => +v);
    let a = lines[0].split(/\s/).slice(0, n).map(v => [+v, +v, 1]).sort((a, b) => b[1] - a[1]);

    for(let i = 0; i < k; i++){
        let max = a[0];
        max[2]++;
        const divided = max[1] = max[0] / max[2];
        let j = 1;
        while(a[j] && a[j][1] > divided)j++;
        a = a.slice(1, j).concat([max]).concat(a.slice(j, n));
    }
    console.log(Math.ceil(a[0][1]));
})()
//  [javascript]
(async () => {
    let input = '';
    for await (const chunk of process.stdin) input += chunk;
    const lines = input.split(/\n/);
    const [n, k] = lines.shift().split(/\s/).map(v => +v);
    let a = lines[0].split(/\s/).slice(0, n).map(v => [+v, +v, 1]);

    for(let i = 0; i < k; i++){
        let max = a.reduce((prev, current) => prev[1] > current[1] ? prev : current);
        max[2]++;
        max[1] = max[0] / max[2];
    }
    let max = a.reduce((prev, current) => prev[1] > current[1] ? prev : current);
    console.log(Math.ceil(max[1]));
})()
//  [javascript]
//解説参照済み

function main(input = "") {
    const lines = input.split("\n");
    const K = 0 | lines[0].split(" ")[1];
    const arr = lines[1].split(" ").map((v) => 0 | v);

    let l = 1;
    let r = Math.max(...arr);
    let mid = 0 | (r + l) * 0.5;
    let res = r;
    while (l <= r) {

        let k = 0;
        arr.forEach((v) => {
            let d = 0 | v / mid;
            if (v === d * mid) { d--; }
            k += d;
        })

        if (k <= K) {
            res = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
        mid = 0 | (r + l) * 0.5;
    }
    return res;
}


//******************************
exports.main = main;

function Main(input) {
    console.log(main(input.trim()));
}

if (process.argv[2] !== "test") {
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, k := io.NextInt(), io.NextInt()
	a := io.NextInts(n)
	ans := solve(n, k, a)
	io.Println(ans)
}

func solve(n, k int, a []int) int {
	divConut := func(x float64) int {
		if x == 0 {
			panic("division by zero")
		}
		cnt := 0
		for i := range a {
			if float64(a[i]) <= x {
				continue
			}
			cnt += int(math.Ceil(float64(a[i])/x)) - 1
		}
		return cnt
	}
	x := sort.Search(maxIter, func(x int) bool { return divConut(float64(x+1)/10) <= k })
	if x == maxIter {
		panic("reached max iteration")
	}
	return int(math.Ceil(float64(x+1) / 10))
}

const maxIter = 1e12

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, k := io.NextInt(), io.NextInt()
	a := io.NextInts(n)
	ans := solve(n, k, a)
	io.Println(ans)
}

func solve(n, k int, a []int) int {
	divConut := func(x float64) int {
		cnt := 0
		for i := range a {
			if float64(a[i]) <= x {
				continue
			}
			cnt += int(math.Ceil(float64(a[i])/x)) - 1
		}
		return cnt
	}
	x := sort.Search(maxIter, func(x int) bool { return divConut(float64(x)/100) <= k })
	if x == maxIter {
		panic("error")
	}
	return int(math.Ceil(float64(x) / 100))
}

const maxIter = 1e12

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, k := io.NextInt(), io.NextInt()
	a := io.NextInts(n)
	ans := solve(n, k, a)
	io.Println(ans)
}

func solve(n, k int, a []int) int {
	if k == 0 {
		return Max(a...)
	}
	divConut := func(x float64) int {
		cnt := 0
		for i := range a {
			if float64(a[i]) <= x {
				continue
			}
			cnt += int(math.Ceil(float64(a[i])/x)) - 1
		}
		return cnt
	}
	x := sort.Search(maxIter, func(x int) bool { return divConut(float64(x)/10) <= k })
	if x == maxIter {
		panic("error")
	}
	return int(math.Ceil(float64(x) / 10))
}

const maxIter = 1e12

// Max returns max value of inputs
func Max(a ...int) (max int) {
	for i, ai := range a {
		if i == 0 || ai > max {
			max = ai
		}
	}
	return max
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, k := io.NextInt(), io.NextInt()
	a := io.NextInts(n)
	ans := solve(n, k, a)
	io.Println(ans)
}

func solve(n, k int, a []int) int {
	if k == 0 {
		return Max(a...)
	}
	divConut := func(x float64) int {
		cnt := 0
		for i := range a {
			cnt += int(float64(a[i]) / x)
		}
		return cnt
	}
	x := sort.Search(maxIter, func(x int) bool { return divConut(float64(x)/10) <= k })
	if x == maxIter {
		panic("error")
	}
	return int(math.Ceil(float64(x) / 10))
}

const maxIter = 1e12

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

// Max returns max value of inputs
func Max(a ...int) (max int) {
	for i, ai := range a {
		if i == 0 || ai > max {
			max = ai
		}
	}
	return max
}
//  [ruby]
N, K = gets.chomp.split.map(&:to_i)
AS = gets.chomp.split.map(&:to_i)

as_sum = AS.sum
num = N + K 
num_cut_float = AS.map { |a| 1.0 * num * a / as_sum }
                  .map { |a| a < 1 ? 1 : a}
num_cut_int = num_cut_float.map(&:to_i)

as_length = []
AS.size.times do |i|
  as_length << (1.0 * AS[i] / num_cut_int[i]).ceil 
end
as_length = as_length.sort.reverse
puts as_length[N + K - num_cut_int.sum]
//  [ruby]
# 入力：N本ある丸太を合計K回切ることができる
N, K = gets.chomp.split.map(&:to_i)

# 入力：N本ある丸太それぞれの長さ
A = gets.chomp.split.map(&:to_i)

# 長さ候補rangeのそれぞれについて、k回で切れるか二分探索
ans = (1 .. A.max).bsearch{|x| A.sum{(_1 - 1) / x} <= K}

# 出力
puts ans
//  [ruby]
n,k=gets.split.map &:to_i
a=gets.split.map &:to_i
p (1..a.max).bsearch{|x|a.sum{(_1-1)/x}<=k}
//  [ruby]
# after YouTube editorial
n,k = gets.strip.split.map(&:to_i)
a = gets.strip.split.map(&:to_i)
l = 1
r = a.max
while r - l > 1
  x = (l+r)/2
  y = 0
  a.each do |e|
    y += (e+x-1)/x-1 if e > x
  end
  if y > k
    l = x
  else
    r = x
  end
end
p r
//  [ruby]
N,K = gets.split.map &:to_i
A = gets.split.map &:to_i

p (1..10**9).bsearch{|l| A.inject(0){|total,a| total+(a.to_r/l).ceil - 1} <= K }
//  [ruby]
# 入力：N本ある丸太を合計K回切ることができる
N, K = gets.chomp.split.map(&:to_i)

# 入力：N本ある丸太それぞれの長さ
A = gets.chomp.split.map(&:to_i)

# 切り終えたとき最大の丸太の長さの候補
range = [1..A.max]

# 長さ候補rangeのそれぞれについて、k回で切れるか二分探索
ans = range.bsearch{|x| A.sum{(_1 - 1) / x} <= K}

# 出力
puts ans
//  [rust]
#![allow(unused_imports)]
#![allow(non_snake_case)]
use proconio::{input, fastout};
use proconio::marker::{Chars, Bytes, Usize1};

#[fastout]
fn main() {
    input!{
        n: usize, k:u32,
        c: [u32; n]
    }
    let mut ng = 0;
    let mut ok = *c.iter().max().unwrap() + 1;
    while ok - ng > 1 {
        let mid = (ok + ng) / 2;
        let mut cnt = 0;
        for &x in &c {
            cnt += (x - 1) / mid;
        }
        if cnt <= k {
            ok = mid
        } else {
            ng = mid
        }
    }
    println!("{}", ok);
}
//  [rust]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::collections::*;

fn main() {
    input! {
        n:usize,
        k:i32,
        a:[i32;n],
    }
    let mut ok = *a.iter().max().unwrap();
    let mut no = 0;
    while (ok - no).abs() > 1 {
        let mid = (ok + no) / 2;
        let ope_num = a
            .iter()
            .fold(0, |acc, &len| acc + (len + mid - 1) / mid - 1);
        if ope_num <= k {
            ok = mid;
        } else {
            no = mid;
        }
    }
    println!("{}", ok);
}
//  [rust]
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;
extern crate num_bigint; // 0.2.2
extern crate num_traits; // 0.2.8
use num_bigint::BigInt;
use num_bigint::ToBigInt;
use num_traits::abs;
use num_traits::Pow;
use num_traits::{One, Zero};

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
// use ascii::Chars;
use proconio::marker::{Bytes, Chars};
use std::cmp::*;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::*;
use std::ops::Range;
use std::str::FromStr;
use superslice::*;

use lazy_static::lazy_static;
use std::sync::Mutex;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

lazy_static! {
    // static ref PARENTS: Mutex<Vec<usize>> = Mutex::default();
    // static ref CHILDS: Mutex<Vec<Vec<usize>>> = Mutex::default();
    static ref ADJ: Mutex<Vec<Vec<usize>>> = Mutex::default();
}

// const MOD: usize = 9997063;
// const MOD: usize = 100_000_000_ + 7;

//tenka1-2019-C
// #[fastout]
fn main() {
    input![n: usize, k: usize, a: [usize; n]];

    let mut ng = -1;
    let mut ok = *a.iter().max().unwrap() as i64;

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while abs(ok - ng) > 1 {
        let mid = (ok + ng) / 2;

        if is_ok(mid, k, &a) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    // return ok;

    println!("{}", ok);
}

fn is_ok(v: i64, k: usize, a: &Vec<usize>) -> bool {
    return a.iter().map(|a| *a as i64 / v).sum::<i64>() <= k as i64;
}

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);

// -100000000
//  1000000000
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        k:usize,
        mut a:[usize;n],
    }
    a.sort();

    let mut l = 1;
    let mut r = a[n-1];

    while l+1 < r{
        let mid = (l+r)/2;
        
        let mut tmp : u128 = 0;
        for e in &a{
            if *e%mid == 0{
                tmp += (*e/mid -1) as u128;
            }else{
                tmp += (*e/mid) as u128;
            }
        }

        if tmp > k as u128{
            l = mid;
        }else{
            r = mid;
        }
    }
    println!("{}",r);
}
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        k:usize,
        mut a:[usize;n],
    }
    a.sort();

    let mut l = 1;
    let mut r = 1_000_000_100;

    while l+1 < r{
        let mid = (l+r)/2;
        
        let mut tmp = 0;
        for e in &a{
            if *e%mid == 0{
                tmp += *e/mid -1;
            }else{
                tmp += *e/mid;
            }
        }

        if tmp > k{
            l = mid;
        }else{
            r = mid;
        }
    }
    println!("{}",r);
}
//  [swift]
import Foundation

func splitCount(_ a: [Int], _ x: Int) -> Int {
  let res = a.reduce(0) { $0 + Int(ceil(Double($1) / Double(x))) - 1 }
  return res
}

let inp = readLine()!.split(separator: " ").map { Int($0)! }
let n = inp[0]
let k = inp[1]

let a = readLine()!.split(separator: " ").map { Int($0)! }

var left = 1
var right = a.max()!

var ans = right

while left <= right {
  let mid = left + (right - left) / 2
  let c = splitCount(a, mid)
  if c <= k {
    ans = min(ans, mid)
    right = mid - 1
  } else {
    left = mid + 1
  }
}
print(ans)
//  [swift]
import Foundation

func readInt() -> Int {
    Int(readLine()!)!
}
 
func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}
 
prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}

func ok(k: Int, a: [Int], v: Int) -> Bool {
    let m = a.lazy.map { 
        Int((Double($0) / Double(v)).rounded(.up)) - 1
    }.reduce(0, +)

    return m <= k
}

func main() {
    let (n, k) = *readInts()
    let a = readInts()

    let ma = a.max()!

    var l = 1
    var r = ma
    while l < r {
        let mid = (l + r) / 2

        if ok(k: k, a: a, v: mid) {
            r = mid
        } else {
            l = mid + 1
        }
    }

    print(r)
}

main()
//  [typescript]
import { readFileSync } from 'fs'

const LOG_MIN_SIZE = 1
const LOG_MAX_SIZE = 1e9

const binarySearch = (min: number, max: number, fn: (value: number) => boolean) => {
  let left = min
  let right = max

  while (left < right) {
    const middle = Math.floor((left + right) / 2)
    const result = fn(middle)

    if (result) {
      right = middle
    }
    else {
      left = middle + 1
    }
  }

  return left
}

function main(input: string) {
  const [n, k, ...logs] = input.split(/\s/).map(Number)

  const result = binarySearch(LOG_MIN_SIZE, LOG_MAX_SIZE, x => {
    // 各丸太の長さが`x`以下になるのに必要なカット回数
    const cuts = logs.reduce((sum, v) => sum + Math.ceil(v / x) - 1, 0)

    return cuts <= k
  })

  console.log(result)
}

main(readFileSync('/dev/stdin', 'utf8').trim())
//  [typescript]
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [_N, K] = r.nn()
    const A = r.nn()

    const al = A.map(Math.log2)

    let lo = 0
    let hi = Math.log2(10 ** 9)
    let mid = 0

    // console.log(al)

    while (hi > lo) {
      mid = (hi + lo) / 2

      let sumK = 0

      al.forEach((ai) => {
        if (mid <= ai) {
          sumK += Math.ceil(ai - mid)
        }
      })
      // console.log(mid)
      // console.log(sumK)

      if (sumK === K && hi - lo < 0.001) {
        break
      }
      if (sumK > K) {
        lo = mid
      } else {
        hi = mid
      }
    }
    // console.log(mid)

    return Math.ceil(Math.pow(2, mid) - 0.00001)
  }

  const _io = (i = 0) => {
    const str: string = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}
//  [typescript]
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
//const input = fs.readFileSync('./input.txt', 'utf8');

_f(input);

function _f(input: string) {
  const [_NK, _A] = input.split('\n');
  const [N, K] = _NK.split(' ').map((s) => parseInt(s));
  const A = _A.split(' ').map((s) => parseInt(s));

  const sum = A.reduce((p, c) => p + c, 0);

  console.log(Math.ceil(sum / (N + K)));
}
//  [python]
import sys
readline=sys.stdin.readline

X,N=map(int,readline().split())
P=set(list(map(int,readline().split())))

x = X
while x in P:
  x -= 1

minX = x

x = X
while x in P:
  x += 1
maxX = x

if abs(minX - X) <= abs(maxX - X):
  print(minX)
else:
  print(maxX)
//  [python]
X, N = map(int, input().split())
if N == 0:
    print(X)
else:
    p = sorted(map(int, input().split()))
    nums = [num for num in range(102) if not num in p]
    A = [abs(num - X) for num in nums]
    print(nums[A.index(min(A))])
//  [python]
def main():
    x, n = list(map(int, input().split()))
    if n == 0:
        print(x)
        exit()
    else:
        P = list(map(int, input().split()))
    S = set(range(102)) - set(P)
    ans = float('inf')
    ans_p = 0
    for s in S:
        r = abs(s - x)
        if r < ans:
            ans = r
            ans_p = s
        elif r == ans:
            if ans_p > s:
                ans_p = s
    print(ans_p)
if __name__ == '__main__':
    main()
//  [python]
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import breadth_first_order, depth_first_order, shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

X, N = na()
p = na()
kouho = []
for i in range(-100, 101):
    if i in p:
        continue
    kouho.append((abs(X - i), i))
print(min(kouho)[1])
//  [python]
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import breadth_first_order, depth_first_order, shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

X, N = na()
p = na()
kouho = []
for i in range(1, 101):
    if i in p:
        continue
    kouho.append((abs(X - i), i))
print(min(kouho)[1])
//  [python]
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import breadth_first_order, depth_first_order, shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

X, N = na()
p = na()
res = inf
ans = inf
for i in range(1, 101):
    if i in p:
        continue
    kouho = abs(X - i)
    if res <= kouho:
        break
    else:
        res = kouho
        ans = i
print(ans)
//  [java]
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String args[]) throws Exception {
        String[] tokens = br.readLine().split(" ");
        int x = Integer.parseInt(tokens[0]);
        int n = Integer.parseInt(tokens[1]);
        Set<Integer> set = new HashSet<>();
        if(n>0){
            tokens = br.readLine().split(" ");
            for(int i=0;i<n;i++){
                set.add(Integer.parseInt(tokens[i]));
            }
        }
        int ans = x;
        for(int diff=0;diff<=Integer.MAX_VALUE;diff++){
            int left = x-diff;
            int right = x+diff;
            if(!set.contains(left)){
                ans = left;
                break;
            }
            if(!set.contains(right)){
                ans = right;
                break;
            }
        }
        System.out.println(ans);
    }




    private static class Pair{
        int first,second;

        public Pair(int first,int second){
            this.first = first;
            this.second = second;
        }

        public int hashCode(){
            return Objects.hash(first,second);
        }

        public boolean equals(Object obj){
            if(obj!=null || !(obj instanceof  Pair))
                return false;
            Pair pair = (Pair)obj;
            return pair.first == first && pair.second == second;
        }
    }




}
//  [java]
import java.util.*;
import java.math.BigDecimal;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int x = sc.nextInt();
        int n = sc.nextInt();
        int check = n;
        int z= 999;
        int p[] = new int[n];
        int ans = 100;
        HashSet hs = new HashSet();
        for(int i = 0; i < n;i++){
          hs.add(sc.nextInt());
        }
        
        hs.add(x);
        if(hs.size() != n){
          System.out.println(x);
          System.exit(0);
        }
        for(int i = -100; i <= 100;i++){
          hs.add(i);
          if(hs.size() != check){
            if(Math.abs(x - i) < ans){
              ans = x - i;
              z = i;
            }
            check++;
          }
        }
        

        System.out.println(z);
    }
}
//  [java]
import java.util.*;
import java.math.BigDecimal;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int x = sc.nextInt();
        int n = sc.nextInt();
        int check = n;
        int z= 0 ;
        int p[] = new int[n];
        int ans = 100;
        HashSet hs = new HashSet();
        for(int i = 0; i < n;i++){
          hs.add(sc.nextInt());
        }
        hs.add(x);
        if(hs.size() != n){
          System.out.println(x);
          System.exit(0);
        }
        for(int i = 1; i <= 100;i++){
          hs.add(i);
          if(hs.size() != check){
            if(Math.abs(x - i) < ans){
              ans = x - i;
              z = i;
            }
            check++;
          }
        }
        

        System.out.println(z);
    }
}
//  [java]
import 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();
        int[] p = new int[N];
        boolean[] q = new boolean[101];
        for(int i=0; i<N; i++){
            p[i]=sc.nextInt();
            q[p[i]] = true;
        }

        int res=X;
        for(int i=0; i<X+1; i++){
            if(!q[X-i]){
                res=X-i;
                System.out.println(res);
                return;
            }
            if(!q[X+i]){
                res=X+i;
                System.out.println(res);
                return;
            }
        }
        
        System.out.println(-1);
        
    
        }
    }
//  [cpp]
#include<cstdio>
using namespace std;
int a[105];
int main()
{
	int x,n,q;
	scanf("%d%d",&x,&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&q);
		a[q]=1;
	}
	if(a[x]!=1)
	{
		printf("%d\n",x);
		return 0;
	}
	for(int i=1;i<=101;i++)
	{
		int l=x-i;
		int r=x+i;
		if(a[l]==0)
		{
			printf("%d\n",l);
			return 0;
		}
		if(a[r]==0)
		{
			printf("%d\n",r);
			return 0;
		}
	}
	return 0;
}
//  [cpp]
#include <cstdio>
#include <algorithm>
using namespace std;
int vis[110];
int main(){
	int x,n,i,a,l,r;
	scanf("%d%d",&x,&n);
	if(n==0){printf("%d\n",x);return 0;}
	for(i=1;i<=n;i++)scanf("%d",&a),vis[a]=1;
	if(!vis[x]){printf("%d\n",x);return 0;}
	l=r=x;
	while(1){
		l--,r++;
		if(!vis[l]){printf("%d\n",l);break;}
		if(!vis[r]){printf("%d\n",r);break;}
	}
	return 0;
}
//  [cpp]
#include <cstdio>
#include <algorithm>
using namespace std;
int x,n,s,f;
int p[105];
int main(){
	scanf("%d%d",&x,&n);
	for(int i=1;i<=n;++i){
		scanf("%d",p+i);
	}
	p[n+1]=100001;
	p[0]=-100001;
	sort(p+1,p+1+n);
	for(int i=0;i<=n;++i){
		if(p[i]<=x&&x<p[i+1]){
			s=i;
			f=i+1;
			break;
		}
	}
	for(int i=0;i<=1000;++i){
		if(p[s]!=x-i){
			printf("%d\n",x-i);
			return 0;
		}
		else s--;
		if(i==0)continue;
		if(p[f]!=x+i){
			printf("%d\n",x+i);
			return 0;
		}
		else f++;
	}
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
# define LL long long

int main(){
    int p[101]={0};
    int x,n;
    scanf("%d%d",&x,&n);
    for (int i=0;i<n;i++){
        int y;
        scanf("%d",&y);
        p[y]+=1;
    }
    int i=x,j=x,ans;
    while (1){
        if (p[i]==0){
            ans=i;
            break;
        }
        if (p[j]==0){
            ans=j;
            break;
        }
        else{
            i-=1;
            j+=1;
        }
    }
    printf("%d",ans);
}
//  [cpp]
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const ll INF=1e17;
const long double PI=acos(-1);

ll po(int x){
    if(x==0){
        return 1;
    }
    ll ret=1;
    for(int i=0;i<x;i++){
        ret=(ret%MOD * 10)%MOD;
    }
    return ret;
}
bool a[200];

void solve(int T){
    int x,n;
    cin>>x>>n;
    if(n==0){
        cout<<x;
        return;
    }
    for(int i=0;i<n;i++){
        int r;
        cin>>r;
        a[r]=true;
    }
    int mn=102,ans=102;
    for(int i=1;i<=101;i++){
        if(a[i]==false){
            if(abs(x-i)<mn){
                ans=i;
                mn=abs(x-i);
            }
        }
    }
    cout<<ans<<"\n";
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}
/*

for(int i=1;i<n;i++){
        for(int j=1;j<n;j++){
            cout<<i<<" "<<j<<" "<<n-(i*j)<<"\n";
        }
    }
    */
//  [cpp]
#include<bits/stdc++.h>
#include<vector>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    int x, n;
    cin >> x >> n;
    int p[n];

    //solve
    int stock[101];
    int ans1, ans2;
    for(int i=0; i<n; i++){
        cin >> p[i];
        stock[p[i]] = 1;
    }
    for(int i = x; i < 100; i++){
        if(stock[i+1] == 0){
            ans1 = abs(i+1-x);
            break;
        }
    }
    for(int i = x; i>0; i--){
        if(stock[i-1] == 0){
            ans2 = abs(i-1-x);
            break;
        }
    }
    ans1 = min(ans1, ans2);

    cout << ans1 <<endl;

    return 0;
}
//  [c]
#include<stdio.h>
signed main(){
    int x,n,p[105];
    scanf("%d %d",&x,&n);
    int i;
    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    int flag[105]={};
    int ans=0;
    for(i=0;i<n;i++){
        flag[p[i]]=1;
    }
    for(i=1;i<=101;i++){
        if(flag[i]==0){
            int abs1,abs2;
            abs1=x-ans;
            abs2=x-i;
            if(abs1<0){
                abs1=abs1*-1;
            }
            if(abs2<0){
                abs2=abs2*-1;
            }
            if(abs1>abs2){
                ans=i;
            }
        }
    }
    printf("%d\n",ans);
    return(0);
}
//  [c]
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long
#define pai 3.1415926535897932384626433832795028841971693

int main(){
  int x,n,min=100001,ans=0,k;
  scanf("%d %d",&x,&n);
  int p[n],a[n];
  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
  }

  for(int i=-1;i<201;i++){
    for(int j=0;j<n;j++){
      if(i==p[j]){
        k=1;
        break;
      }
      k=0;
    }
    if(k==1){
      continue;
    }
    else{
      if(min>abs(x-i)){
        min=abs(x-i);
        ans=i;
      }
      else if(min==abs(x-i)){
        if(ans>i){
          ans=i;
        }
      }
    }
  }
  printf("%d",ans);
   return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>

int main(void){

    int x,n;

    scanf("%d %d",&x,&n);
    // printf("%d %d",x,n);
    if (n==0){
        printf("%d\n",x);
        return 0;
    }

    int p[n];
    int min=0;
    int ans=0;
    int flag=0;

    for (int i=0;i<n;i++){
        scanf("%d",&p[i]);
        if (x==p[i])
            flag=1;
    }

    if (flag==0){
        printf("%d\n",x);
        return 0;
    }

    for (int i=1;i<100;i++){
        int flag1=0;
        int flag2=0;
        for (int j=0;j<n;j++){
            if (x-i==p[j])
                flag1=1;
            else if (x+i==p[j])
                flag2=1;
        }
        // printf("i=%d flag1=%d flag2=%d\n",i,flag1,flag2);
        if ((flag1==0 && flag2==0) || (flag1==0 && flag2==1)){
            printf("%d\n",x-i);
            break;
        }else if (flag1==1 && flag2==0){
            printf("%d\n",x+i);
            break;
        }

    }
    
    return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>

int main(){
        int i, x, n, left=103, right=103;
        scanf("%d %d", &x, &n);

        if(n==0){
                printf("%d", x);
                return 0;
        }

        int p[101]={0};
        int pp;

        for(i=0; i<n; i++){
                scanf("%d", &pp);
                p[pp]=1;
        }

        int count=0;

        for(i=0; i<101; i++){
                if(p[x+i]!=1){
                        right=x+i;
                        count++;
                }
                if(p[x-i]!=1){
                        left=x-i;
                        count++;
                }

                if((count!=0)&&(left>right)){
                        printf("%d", right);
                        return 0;
                }else if((count!=0)&&(right>left)){
                        printf("%d", left);
                        return 0;
                }

        }

        return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>

int main(){
        int i, x, n, left=103, right=103;
        scanf("%d %d", &x, &n);

        if(n==0){
                printf("%d", x);
                return 0;
        }

        int p[101]={0};
        int pp;

        for(i=0; i<n; i++){
                scanf("%d", &pp);
                p[pp]=1;
        }

        int count=0;

        for(i=1; i<101; i++){
                if(p[x+i]!=1){
                        right=x+i;
                        count++;
                }
                if(p[x-i]!=1){
                        left=x-i;
                        count++;
                }

                if((count!=0)&&(left>right)){
                        printf("%d", right);
                        return 0;
                }else if((count!=0)&&(right>left)){
                        printf("%d", left);
                        return 0;
                }

        }

        return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void){
    int X, N, i, j, k, min=100, min_index=0, flag=0;
    scanf("%d%d", &X, &N);
    int p[N+1], b[101];
    for(i=1; i<=N; i++){
        scanf("%d", &p[i]);
        b[i]=0;
    }
    for(i=0; i<=N; i++){
        b[p[i]]=1;
    }
    for(i=0; i<=101; i++){
        if(N==0){
            printf("%d", X);
            flag=1;
            break;
        }else if(min>abs(X-i) && b[i]==0 && min_index<=i){
            min = abs(X-i);
            min_index=i;
        }
    }

    if(flag==0){
        printf("%d", min_index);
    }

    return 0;
}
//  [javascript]
const main = (input) => {
  const args = input.trim().split("\n");
  const [x, n] = args[0]
    .trim()
    .split(" ")
    .map((n) => parseInt(n, 10));

  const excluded = (() => {
    if (n === 0) {
      return [];
    } else {
      return args[1]
        .trim()
        .split(" ")
        .map((n) => parseInt(n, 10));
    }
  })();

  const selection = [...Array(101 + 1).keys()].filter(
    (s) => !excluded.includes(s)
  );

  const abs = (n) => {
    if (n < 0) return -n;
    else {
      return n;
    }
  };
  const byAsc = (a, b) => a[1] - b[1];

  const answer = selection
    .map((s) => [s, abs(x - s)])
    .sort(byAsc)[0][0];

  console.log(answer);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    let X = parseInt(arg[0].split(" ")[0]);
    const N = parseInt(arg[0].split(" ")[1]);
    
    if(!arg[1]) {
      console.log(X);
      return;
    }
  
    const P = arg[1].split(" ").map(n=>parseInt(n));
    let cnt = 1;
    
    while(true) {
        if(P.indexOf(X) === -1) {
            console.log(X);
            return;
        }
      
        let answer1;
        let answer2;
      
        if(P.indexOf(X - cnt) === -1) {
            answer2 = X - cnt;
            console.log(answer2);
            return;
        }
        
        if(P.indexOf(X + cnt) === -1) {
            answer1 = X + cnt;
            console.log(answer1);
            return;
        }
       
      	cnt++;
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
    const rows = input.split('\n')
    const [X, N] = rows[0].split(' ').map(n => n - 0)
    const P = rows[1].split(' ').map(n => n - 0)

    for (let i = 0; i < 52; i++) {
        if (P.indexOf(X - i) === -1) {
            console.log(X - i)
            break
        }
        if (P.indexOf(X + i) === -1) {
            console.log(X + i)
            break
        }
    }

})(input)
//  [javascript]
const main = (input) => {
  input = input.trim().split('\n')

  const [x,] = input[0].split(' ').map(Number)
  if (input.length === 1) return console.log(x)
  const arr = input[1].split(' ').map(Number).sort((a, b) => a - b)

  for (let abs = 1; 'infinite'; abs++) {
    if (!arr.includes(x - abs)) return console.log(x - abs)
    if (!arr.includes(x + abs)) return console.log(x + abs)
  }
}

process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
function Main(input) {
  input=input.split("\n");
  const X=input[0].split(' ')[0]-0;
  const N=input[0].split(' ')[1]-0;
  
  var array=input[1].split(' ').map(e=>{
    return e-0;
  }).sort((a,b)=>{
    return Math.abs(a-X)-Math.abs(b-X)||a-b;
  });
  var counter=0;
  while(counter<array.length){
    if(Math.abs(array[counter]-X)!==Math.floor((counter+1)/2)){
      console.log(counter%2===0?X+Math.floor((counter+1)/2):X-Math.floor((counter+1)/2));
      return;
    }
    counter++;
  }
  counter--;
  console.log(N%2===0?X+Math.floor((counter+1)/2):X-Math.floor((counter+1)/2)-1);
  
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'

const main = (INPUT) => {
  const [X, N] = INPUT.split('\n')[0].split(' ').map(n => Number(n))
  const p = INPUT.split('\n')[1].split(' ').map(n => Number(n))
  if (N == 0) {
    console.log(X)
    return
  }
  let i = 1
  while (true) {
    if (!p.includes(X - i)) {
      console.log(X - i)
      return
    }
    if (!p.includes(X + i)) {
      console.log(X + i)
      return
    }
    i++
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func arrayContains(arr []int, num int) bool {
	for _, v := range arr {
		if v == num {
			return true
		}
	}
	return false
}

func main() {
	var x, n int
	var pt []string
	var p []int
	fmt.Scan(&x, &n)

	if n == 0 {
		fmt.Print(x)
		return
	}

	sc := bufio.NewScanner(os.Stdin)

	if sc.Scan() {
		pt = strings.Split(sc.Text(), " ")
	}

	for _, e := range pt {
		num, _ := strconv.Atoi(e)
		p = append(p, num)
	}

	i := 1
	current := x
	for {
		if !arrayContains(p, current) {
			fmt.Print(current)
			return
		}

		if current == x {
			current = x - 1
			continue
		}
		if current < x {
			current = x + i
		} else {
			i += 1
			current = x - i
		}
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var x, n int
	fmt.Scanf("%d %d", &x, &n)

	sc.Split(bufio.ScanWords)

	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	for i:=0; i < 100; i++ {
		if !contains(a, x-i) {
			fmt.Println(x-i)
			return
		}
		if !contains(a, x+i) {
			fmt.Println(x+i)
			return
		}
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"math"
)

var sc = bufio.NewScanner(os.Stdin)

// 1行読み込み
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 読み込みをint型へキャスト
func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if(err != nil) {
		panic(err)
	}
	return num
}

// 読み込みをfloat型へキャスト
func nextFloat() float64 {
	sc.Scan()
	num, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return num
}

func main() {
	// scannerの挙動を改行区切り → 空白区切りに変更
	sc.Split(bufio.ScanWords)
	x := nextInt()
	n := nextInt()
	p_list := make([]int, 0, n)
	if n == 0 {
		fmt.Println(x)
		return
	}
	for i := 0; i < n; i++ {
		p_list = append(p_list, nextInt())
	}
	p_check := make([]int, 200, 200)
	// p_check[x - 1]++
	for _, i := range p_list {
		p_check[i - 1]++
	}

	x_next := x
	x_befo := x
	for i := x; i < 1000; i++ {
		if p_check[i - 1] == 0 {
			x_next = i
			break
		}
	}
	for i := x; i > -1000; i-- {
		if i == 0 {
			x_befo = i
			break
		}
		if p_check[i - 1] == 0 {
			x_befo = i
			break
		}
	}
	next_abs := int(math.Abs(float64(x_next - x)))
	befo_abs := int(math.Abs(float64(x_befo - x)))

	if next_abs == befo_abs {
		fmt.Println(x_befo)
	} else if next_abs > befo_abs {
		fmt.Println(x_befo)
	} else {
		fmt.Println(x_next)
	}
}
//  [go]
package main

import (
	"fmt"
	"math"
)

func main() {
	var X, n, p int
	var P [101]int
	var tmp float64
	tmp = 100000
	ans := 0

	fmt.Scan(&X, &n)

	for i := 0; i < n; i++ {
		fmt.Scan(&p)
		P[p] = 1
	}

	for i := 0; i < 101; i++ {
		if P[i] == 0 {
			if float64(tmp) > math.Abs(float64(X - i)) {
				ans = i
				tmp = math.Abs(float64(X - i))
			}
		}
	}
	fmt.Println(ans)
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	//存在するものが1になる
	a := make([]int, 100)

	var x, n int
	fmt.Scanf("%d", &x)
	fmt.Scanf("%d", &n)

	var p int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &p)
		a[p - 1] = 1
	}

	if n == 0 {
		fmt.Println(x)
	}else{
		i := 0
		for {
			c := x - 1 - i
			if c > -1 && a[c] == 0 {
				fmt.Println(c + 1)
				break;
			}

			c = x - 1 + i
			if c < 100 && a[c] == 0 {
				fmt.Println(c + 1)
				break;
			}

			i = i + 1
		}
	}
}
//  [ruby]
x, n = gets.split.map(&:to_i)
if n==0
  p x
  exit
end
p = gets.split.map(&:to_i)
if !p.include?(x)
  p x
  exit
end
100.times{|i|
  if !p.include?(x-i)
    p x-i
    exit
  end
  if !p.include?(x+i)
    p x+i
    exit
  end
}
//  [ruby]
input = readlines()

meta = input.shift.chomp.split("\s").map{|x| x.to_i}

target_num = meta[0]

forbid_list = input.shift.split("\s").map{|x| x.to_i}

nearlest = nil
n_abs = nil
(-100..200).each do |x|
  next if forbid_list.include?(x)
  c_abs = (target_num - x).abs
  if n_abs.nil? || c_abs <= n_abs
    if n_abs.nil? || c_abs < n_abs
      nearlest = x
      n_abs = c_abs
      next
    end
    if c_abs == n_abs && nearlest > x
      nearlest = x
      n_abs = c_abs
    end
  end
end

puts nearlest
//  [ruby]
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

x,n = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)


a.sort!
if !a.include?(x)
  puts x
else
  num = 1
  while true
    if a.include?(x-num)
      if a.include?(x+num)
        num += 1
      else
        puts (x+num)
        break
      end
    elsif !a.include?(x-num)
      puts (x-num)
      break
    else
      puts (x+num)
      break
    end
  end
end

# 6 5
# 4 7 10 6 5
//  [ruby]
x, n = gets.split(' ').map(&:to_i)
ps = n == 0 ? [] : gets.split(' ').map(&:to_i)

result = 100
min_abs = 100

target_arr = (0..100).to_a.select { |i| !ps.include?(i) }

target_arr.each do |i|
  abs = (x - i).abs
  if abs < min_abs
    result = i
    min_abs = abs
  elsif abs == min_abs && i < result
    result = i
  end
end

puts result
//  [ruby]
x, n = gets.split.map(&:to_i)
if n != 0
  p = gets.split.map(&:to_i)
end
    i = 1
ans = nil

if n == 0
  puts x
elsif n != 0
  while ans == nil
    if p.include?(x - i) == false && p.include?(x + i) == false
      ans = x - i
    elsif p.include?(x - i) == false
      ans = x - i
    elsif p.include?(x + i) == false
      ans = x + i
    else i += 1
    end
  end
end

puts ans
//  [ruby]
x, n = gets.split.map(&:to_i)
if n != 0
  p = gets.split.map(&:to_i)
end

ans = nil

if n == 0
  puts x
elsif n != 0
  200.times{|i|
    break if ans != nil
    if p.include?(x - (i+1)) == false && p.include?(x + (i+1)) == false
      ans = x - (i+1)
    elsif p.include?(x - (i+1)) == false
      ans = x - (i+1)
    elsif p.include?(x + (i+1)) == false
      ans = x + (i+1)
    end
   }
end

puts ans
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashSet;
fn main() {
    input! {
        x: i32,
        n: i32,
        p: [i32; n],
    }
    let p: HashSet<_> = p.into_iter().collect();
    for i in 0..102 {
        for j in &[x - i, x + i] {
            if !p.contains(j) {
                println!("{}", j);
                return;
            }
        }
    }
}