Bubble sort repeatedly compares two adjacent values in an array and swaps them when the left value is greater than the right value. An integer array A[0], A[1], ..., A[N-1] contains N distinct integers. To sort A in ascending order, Taeguk wrote the following code.
Depending on the input array, however, the array may become sorted before variable i finishes every iteration. Dohyun improved the code so that it stops as soon as one full outer iteration performs no swaps.
Given array A, determine the value stored in variable i at the moment the improved code finishes sorting and leaves the outer for loop.