Rightmost element is always leader
print max_from_right , NEW_LINE for i in range ( size - 2 , - 1 , - 1 ) : NEW_LINE INDENT if max_from_right < arr [ i ] : NEW_LINE INDENT print arr [ i ] , NEW_LINE max_from_right = arr [ i ] NEW_LINE DEDENT DEDENT