defmodule Main do

  def main do
    [x, _n] = IO.gets("")
             |> String.trim()
             |> String.split()
             |> Enum.map(&String.to_integer/1)

    p    = IO.gets("")
           |> String.trim()
           |> String.split()
           |> Enum.map(&String.to_integer/1)

    right = x..101 |> Stream.filter(fn k -> not Enum.member?(p, k) end) |> Enum.take(1)  |> List.first()
    left  = 0..x   |> Stream.filter(fn k -> not Enum.member?(p, k) end) |> Enum.take(-1) |> List.first()

    min(left, right) |> IO.puts()
  end
end
