def abc170_c():

    def solve():

        x, n = list(map(int, input().split(' ')))

        if n == 0:

            return x



        p = list(map(int, input().split(' ')))



        search_range_min = min(min(p), x) - 1

        search_range_max = max(max(p), x) + 1

        search_values = [i for i in range(search_range_min, search_range_max + 1) if i not in p]



        check_dict = {}



        for i in search_values:

            # 絶対値が小さいものを調べるので差の絶対値を格納

            check_dict[i] = abs(x - i)



        return min(check_dict, key=check_dict.get)

    print((solve()))



if __name__ == '__main__':

    abc170_c()
def abc170_c_1():

    """

    もうちょいコンパクトに書いてみる

    """

    def solve():

        x, n = list(map(int, input().split(' ')))

        if n == 0:

            return x



        p = list(map(int, input().split(' ')))



        search_range_min = min(min(p), x) - 1

        search_range_max = max(max(p), x) + 1

        search_values = [i for i in range(search_range_min, search_range_max + 1) if i not in p]



        ans = min(search_values, key=lambda a: abs(a - x))



        return ans

    

    print((solve()))



if __name__ == '__main__':

    abc170_c_1()

def abc170_c():
    def solve():
        x, n = list(map(int, input().split(" ")))
        if n == 0:
            return x
        p = list(map(int, input().split(" ")))
        search_range_min = min(min(p), x) - 1
        search_range_max = max(max(p), x) + 1
        search_values = [
            i for i in range(search_range_min, search_range_max + 1) if i not in p
        ]
        check_dict = {}
        for i in search_values:
            # 絶対値が小さいものを調べるので差の絶対値を格納
            check_dict[i] = abs(x - i)
        return min(check_dict, key=check_dict.get)

    print((solve()))


if __name__ == "__main__":
    abc170_c()

def abc170_c_1():
    """
    もうちょいコンパクトに書いてみる
    """

    def solve():
        x, n = list(map(int, input().split(" ")))
        if n == 0:
            return x
        p = list(map(int, input().split(" ")))
        search_range_min = min(min(p), x) - 1
        search_range_max = max(max(p), x) + 1
        search_values = [
            i for i in range(search_range_min, search_range_max + 1) if i not in p
        ]
        ans = min(search_values, key=lambda a: abs(a - x))
        return ans

    print((solve()))


if __name__ == "__main__":
    abc170_c_1()

-def abc170_c(): +def abc170_c_1(): +    """ +    もうちょいコンパクトに書いてみる +    """ + -        check_dict = {} -        for i in search_values: -            # 絶対値が小さいものを調べるので差の絶対値を格納 -            check_dict[i] = abs(x - i) -        return min(check_dict, key=check_dict.get) +        ans = min(search_values, key=lambda a: abs(a - x)) +        return ans -    abc170_c() +    abc170_c_1()