def solution(xs): # Test edge case of just one array value try: xs[1] except IndexError: return str(xs[0]) # Set initial values maxCap = xs[0] smallestNegative = -9223372036854775808 # Largest Negative Starting Value # One time check to see if maxCa[ contains a negative value if maxCap > smallestNegative and maxCap < 0: smallestNegative = maxCap # Loop through the rest of array for item in xs[1:]: if item > smallestNegative and item < 0: smallestNegative = item if item != 0: maxCap *= item # If the value ends on negative - undo the smallest multipication for the biggest number if maxCap < 0: maxCap /= smallestNegative return str(maxCap)