def solution(A, N) -> int:
    i = 1
    while True:
        if i not in A:
            return i
        i += 1

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