import Foundation

func readInt() -> [Int]{
    return readLine()!.split(separator:" ").map{Int($0)!}
}

let xn = readInt()
let array = readInt()
for i in 0...xn[1]{
  guard let s = array.index(of: xn[0] - i) else{
    print(xn[0] - i)
    break
  }
  guard let t = array.index(of: xn[0] + i) else{
    print(xn[0] + i)
    break
  }
}