Minimum cost increasing sequence

Transform A into a strictly increasing integer sequence B minimizing the sum of |B_i - A_i|, and output the lexicographically smallest such B.

Hard9Dynamic programmingGreedyHeapNo attempts yetTime limit2sMemory limit512 MB

Problem

You are given an integer sequence A1,A2,,ANA_1, A_2, \dots, A_N of length NN.

Among the integer sequences BB that satisfy B1<B2<<BNB_1 < B_2 < \dots < B_N, find one that minimizes B1A1+B2A2++BNAN|B_1 - A_1| + |B_2 - A_2| + \dots + |B_N - A_N|. Every element of BB fits in a signed 32-bit integer.

Several sequences BB can reach the minimum sum. Print the lexicographically smallest one, so make B1B_1 as small as possible, then fix that value and make B2B_2 as small as possible, and continue in the same way.

Input

The first line contains NN. (1N1061 \le N \le 10^6)

The second line contains A1,A2,,ANA_1, A_2, \dots, A_N separated by spaces. (0Ai2×1090 \le A_i \le 2 \times 10^9)

Output

Print the lexicographically smallest optimal sequence BB on NN lines, one element per line.

Hint

For A={9,4,8,20,14,15,18}A = \{9, 4, 8, 20, 14, 15, 18\} the minimum sum is 1313. More than one BB reaches it, and B={6,7,8,13,14,15,18}B = \{6, 7, 8, 13, 14, 15, 18\} also has sum 1313. The lexicographically smallest one is B={3,4,8,13,14,15,18}B = \{3, 4, 8, 13, 14, 15, 18\}.