Tests for Haybales

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

문제

Farmer John's cows have decided to offer a programming contest for the cows on Farmer Nhoj's farm. In order to make the problems as fun as possible, they have spent considerable time coming up with challenging input cases. For one problem in particular, "Haybales", the cows need your help devising challenging inputs. This involve solving the following somewhat intriguing problem:

There is an array of sorted integers x_1x_2x_Nx\_1 \leq x\_2 \leq \dotsb \leq x\_N (1N1051 \leq N \leq 10^5), and an integer KK. You don't know the array or KK, but you do know for each index ii, the largest index j_ij\_i such that x_j_ix_i+Kx\_{j\_i} \leq x\_i + K. It is guaranteed that ij_ii\le j\_i and j_1j_2j_NNj\_1\le j\_2\le \cdots \le j\_N\le N.

Given this information, Farmer John's cows need to construct any array along with some integer KK that matches that information. The construction needs to satisfy 0x_i10180 \leq x\_i \leq 10^{18} for all ii and 1K10181 \leq K \leq 10^{18}.

It can be proven that this is always possible. Help Farmer John's cows solve this problem!

입력

The first line of input contains NN. The next line contains j_1,j_2,,j_Nj\_1,j\_2,\ldots,j\_N.

출력

Print KK, then x_1,,x_Nx\_1,\ldots,x\_N on separate lines. Any valid output will be accepted.

힌트

The sample output is the array a=\[1,6,17,22,27,32]a = \[1, 6, 17, 22, 27, 32] with K=6K = 6. j_1=2j\_1 = 2 is satisfied because a_2=61+6=a_1+Ka\_2 = 6 \leq 1 + 6 = a\_1 + K but a_3=17>1+6=a_1+Ka\_3 = 17 > 1 + 6 = a\_1 + K, so a_2a\_2 is the largest element that is at most a_1a\_1. Similarly,

  • j_2=2j\_2 = 2 is satisfied because a_2=66+6a\_2 = 6 \leq 6 + 6 but a_3=17>6+6a\_3 = 17 > 6 + 6
  • j_3=4j\_3 = 4 is satisfied because a_4=2217+6a\_4 = 22 \leq 17 + 6 but a_5=27>17+6a\_5 = 27 > 17 + 6
  • j_4=5j\_4 = 5 is satisfied because a_5=2722+6a\_5 = 27 \leq 22 + 6 but a_5=32>22+6a\_5 = 32 > 22 + 6
  • j_5=6j\_5 = 6 is satisfied because a_6=3227+6a\_6 = 32 \leq 27 + 6 and a_6a\_6 is the last element of the array
  • j_6=6j\_6 = 6 is satisfied because a_6=3232+6a\_6 = 32 \leq 32 + 6 and a_6a\_6 is the last element of the array

This is not the only possible correct output for the sample input. For example, you could instead output the array \[1,2,4,5,6,7]\[1, 2, 4, 5, 6, 7] with K=1K = 1.