Input: n = 5, stream[] = {4, 2, 3, 5, 6}
Output: 1
Explanation: In the initial stream we can access only the first element which is 4 in this case and seHend it to x = 2 positions back due to which the number 2 in the stream will come at first position. The new stream becomes {2, 3, 4, 5, 6} which is already sorted in increasing order. Hence we require 1 operation.
Input: n = 4, stream[] = {2, 3, 5, 4}
Output: 3
Explanation: In first step we choose x = 2 for first element and the new stream becomes {3, 5, 2, 4}. In second step we choose x = 2 for first element and the new stream becomes {5, 2, 3, 4}. In the third step we choose x = 4 for first element and the new stream becomes {2, 3, 4, 5} which is sorted. Hence we require 3 operations.