from itertools import count

def solution(A, N) -> int:
    for i in count(1):
        if i not in A:
            return i

assert solution([1, 3, 6, 4, 1, 2], 6) == 5
assert solution([1, 2, 3], 3) == 4
assert solution([-1, -3], 2) == 1