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
ZnJvbSBpdGVydG9vbHMgaW1wb3J0IGNvdW50CgpkZWYgc29sdXRpb24oQSwgTikgLT4gaW50OgogICAgZm9yIGkgaW4gY291bnQoMSk6CiAgICAgICAgaWYgaSBub3QgaW4gQToKICAgICAgICAgICAgcmV0dXJuIGkKCmFzc2VydCBzb2x1dGlvbihbMSwgMywgNiwgNCwgMSwgMl0sIDYpID09IDUKYXNzZXJ0IHNvbHV0aW9uKFsxLCAyLCAzXSwgMykgPT0gNAphc3NlcnQgc29sdXRpb24oWy0xLCAtM10sIDIpID09IDE=