Loop to find the smaller elements at the right
for i in range ( n - 2 , - 1 , - 1 ) : NEW_LINE INDENT if arr [ i ] > arr [ i + 1 ] : NEW_LINE INDENT dpRight [ i ] = dpRight [ i + 1 ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT dpRight [ i ] = 1 NEW_LINE DEDENT DEDENT totalPrizes = 0 NEW_LINE