
Module Module1

    Sub main()
        Dim user1 = Split(Console.ReadLine(), " ")
        Dim target = user1(0)
        Dim yousosu As Long = CLng(user1(1))


        ' 本来であればここでの条件は不要
        If yousosu = 0 Then

            Console.WriteLine(target)
            Exit Sub
        End If

        Dim user2 = Split(Console.ReadLine(), " ")
        Dim lista2 As Long() = Array.ConvertAll(user2, Function(j As String) CLng(j))
        Dim suretsu = New List(Of Long)(lista2)

        Dim result As Long = target

        ' 対象値より減算し続け存在しないか、また同時に相対値のチェックも行う
        For i = 0 To Math.Floor(yousosu)

            'Console.WriteLine(i & ": " & (target - i).ToString & " , " & target + i & ", " & suretsu.Contains(target + i).ToString)

            If Not suretsu.Contains(target - i) Then
                'Console.WriteLine("★" & i)
                result = target - i
                Exit For
            ElseIf Not suretsu.Contains(target + i) Then
                Console.WriteLine("☆" & i)
                result = target + i
                Exit For
            End If
        Next

        Console.WriteLine(result)
    End Sub
  end module