Loop to find the consecutive smaller elements at right
while ( j < n - 1 && arr [ j ] > arr [ j + 1 ] ) { y ++ ; j ++ ; } totalPrizes += max ( { x , y } ) ; } cout << totalPrizes << endl ; return 0 ; }