Eager Sorting

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Petya is a sorting robot. In his memory, there is an array of length nn (from 11 to 100100), and its elements are pairwise distinct integers. The positions in the array are numbered left to right from 11 to nn.

Nina is a robot operator. Nina wants to sort this array: make it so that, for each two distinct positions, the number on the left is less than the number on the right. The only available command for that is to compare elements at two positions, ii and jj. If the element on the left position (it can be position ii or jj) is greater than the element on the right position, Petya swaps them and displays number 1 on the screen. Otherwise, Petya does nothing with the array and just displays 0 on the screen.

Unfortunately, Petya's power system is damaged, so sometimes the robot shuts down. It looks as follows: when given a command, instead of executing it, Petya just displays -1 on the screen, and then ignores any subsequent commands.

To make Petya work again, Nina disassembles him and then assembles anew. The array is not altered. Unfortunately, during repairs, Nina forgets which commands she already issued to the robot. After that, Petya works as long as his battery lasts, and then shuts down again.

The battery has enough power for Petya to execute 15001500 commands. Petya shuts down exactly twice: after executing xx-th command and after executing 15001500-th command (0<x<15000 < x < 1500, the value of xx is not known to Nina). Knowing all the above, help Nina make it so that, after Petya shuts down for the second time, the array in his memory is sorted.