Hints: Move Back at a Cost
Lexicographic order cares about the first position, then the second, and so on. So you mainly want small numbers early; a big number sitting before a smaller one is suspicious, because you might be able to push the big one toward the end—at the price of increasing it by $1$ each time it is moved back.
Answer to Hint 1: Treat the process as building the final array from left to right. As you read the input, ask: “Should this new value appear before something I was already planning to put earlier?” If the new value is smaller than what you last committed to the “front part,” that older, larger value is blocking a better first position—so it is natural to defer it (send it to the back, paying $+1$) before you place the smaller one.
Answer to Hint 2: You only ever compare the current element with the most recently kept “front” value—like repeatedly undoing a bad last choice when a strictly better smaller value appears. That suggests maintaining those “pending front” values in last-in-first-out order while you sweep the array once.
Answer to Hint 3: Each time you defer a value, remember that it becomes one larger when it lands in the “back” pool. After one left-to-right pass, you have two kinds of objects: a remaining front sequence (never deferred in that sweep) and a multiset of deferred numbers (each already increased by $1$ when it was sent back).
Answer to Hint 4: Among the deferred values, you will eventually want smaller numbers as early as possible in the suffix—so it helps to think of that pool in sorted order (smallest first).
Answer to Hint 5: Compare the smallest deferred value with the last element of the remaining front sequence. If the front’s last element is still larger, it is still blocking: it should be deferred too (again $+1$), and the pool updates. Repeat until the last front element is not larger than the smallest deferred value—then concatenate the front sequence with the sorted pool for the answer.