After iterating over the loop , the remaining elements in stack do not have the next smaller element , so print - 1 for them
while ( s . Count != 0 ) { mp . Add ( s . Peek ( ) , - 1 ) ; s . Pop ( ) ; } for ( int i = 0 ; i < n ; i ++ ) Console . WriteLine ( arr [ i ] + " ▁ - - - > ▁ " + mp [ arr [ i ] ] ) ; }