Find the two indices l , r such that A [ l ] > A [ i ] < A [ r ] and l < i < r using expand function
for ( let i = 0 ; i < N ; ++ i ) { big = Math . max ( big , A [ i ] ) ; mp . set ( i , expand ( i , A ) ) ; iToA . set ( i , A [ i ] ) ; AToi . set ( A [ i ] , i ) ; }