Problem:
Score : 300 points

Problem Statement

Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.

Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Constraints

1 \leq X \leq 100

0 \leq N \leq 100

1 \leq p_i \leq 100

p_1, \ldots, p_N are all distinct.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

X N
p_1 ... p_N

Output

Print the answer.

Sample Input 1

6 5
4 7 10 6 5

Sample Output 1

8

Among the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.

Sample Input 2

10 5
4 7 10 6 5

Sample Output 2

9

Among the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.

Sample Input 3

100 0

Sample Output 3

100

When N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.

Solution in Rust (1.42.0) (judge verdict: Wrong Answer)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
use competitive_tools_rust::io::{parse_tuple2, parse_values};

fn main() {
    let (x, n) = parse_tuple2::<isize>();
    if n == 0 {
        println!("{}", x);
        return
    }
    let p: Vec<isize> = parse_values(n as usize);
    let ok_list = (0..=100).filter(|i| {
        !p.contains(i)
    });
       // .collect::<Vec<usize>>();
    let ans_less = ok_list.clone().filter(|&i| {
        i <= x
    }).min_by(|&a, &b| (a - x).abs().cmp(&(b - x).abs()));
    let ans_more = ok_list.filter(|&i| {
        i > x
    }).min_by(|&a, &b| (a - x).abs().cmp(&(b - x).abs()));
    //println!("{:?}", ans_less);
    //println!("{:?}", ans_more);
    let ans = match (ans_less, ans_more) {
        (None, None) => panic!(),
        (Some(less), None) => less,
        (None, Some(more)) => more,
        (Some(less), Some(more)) => {
            if (less - x).abs() == (more - x).abs() {
                less
            } else {
                *vec![less, more].iter().min_by(|&&l, &m| (l - x).abs().cmp(&(m - x).abs())).unwrap()
            }
        }
    };
    println!("{}", ans);
}
*/

fn main() {
    let exe = "/tmp/binD47D8EEA";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";