Adding the difference of elements at ends of increasing subarray to the answer
if ( arr [ i ] > arr [ i - 1 ] ) : NEW_LINE INDENT Sum += ( arr [ i ] - arr [ i - 1 ] ) NEW_LINE DEDENT return Sum ; NEW_LINE