max_smaller equals to INT_MIN means no element is found in a [ i ] so return 0
if ( max_smaller == - 10 ** 9 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT prev = max_smaller NEW_LINE Sum += max_smaller NEW_LINE return Sum NEW_LINE