Iterate over the array arr [ ] to store length of decreasing sequence that can be obtained at every index in the right array
for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( a [ i ] > a [ i + 1 ] ) { right [ i ] = right [ i + 1 ] + 1 ; }