initialize sum to 0
max_sum = 0 NEW_LINE i = 0 NEW_LINE while i < n : NEW_LINE INDENT current_max = arr [ i ] NEW_LINE k = i NEW_LINE while k < n and ( ( arr [ i ] > 0 and arr [ k ] > 0 ) or ( arr [ i ] < 0 and arr [ k ] < 0 ) ) : NEW_LINE INDENT current_max = max ( current_max , arr [ k ] ) NEW_LINE k += 1 NEW_LINE DEDENT DEDENT