def max_product(A):
    """Calculate maximal product of elements of A"""
product = 1
greatest_negative = float('-inf')
for x in A:
    product = max(product, product * x, key=abs)
if x <= -1:
    greatest_negative = max(x, greatest_negative)
return max(product, product // greatest_negative)
assert max_product([2, 3]) == 6
assert max_product([-2, -3]) == 6
assert max_product([-1, -2, -3, 0, 2]) == 12
assert max_product([]) == 1
assert max_product([-5]) == 1
Найдите подмножество набора целых чисел, которое имеет максимальный продукт