# Write a function:

# def solution(A)

# that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A.

# For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5.

# Given A = [1, 2, 3], the function should return 4.

# Given A = [−1, −3], the function should return 1.

# Write an efficient algorithm for the following assumptions:

# N is an integer within the range [1..100,000];
# each element of array A is an integer within the range [−1,000,000..1,000,000].


# print(format_arr([-1, -3]))

def find_missing_int(A):
	if not A:
		return 1
	A.sort()
	#case where all nums are negative
	if A[-1] <= 0:
		return 1


	for num in range(1, A[-1]):
		# print('num=', num)
		if num>0 and num not in A:
			return num
	return A[-1]+1


# print(find_missing_int([-1, -3])) #1

# print(find_missing_int([-1, -3, 0])) #1
print(find_missing_int([-1, -3, 0, 1])) #2
print(find_missing_int([1, 3,2])) #4
print(find_missing_int([7,8,9,11,12]))#1


def find_missing_int_(A):
	if not A:
		return 1
	#case where all nums are negative
	elif max(A) <= 0:
		return 1


	else:
		pos_nums = []

		for num in A:
			if num >0:
				pos_nums.append(num)


		if min(pos_nums) != 1:
			return 1

		else:
			next_possible_smallest = 2 # the next smallest number 

			while next_possible_smallest in pos_nums:
				next_possible_smallest+=1
			return next_possible_smallest


