Range Reconstruction

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

문제

Bessie has an array a_1,,a_Na\_1, \ldots, a\_N, where 1N3001 \leq N \leq 300 and 0a_i1090 \leq a\_i \leq 10^9 for all ii. She won't tell you aa itself, but she will tell you the range of each subarray of aa. That is, for each pair of indices iji \leq j, Bessie tells you r_i,j=maxa\[ij]mina\[ij]r\_{i, j} = \max a\[i\ldots j] - \min a\[i\ldots j]. Given these values of rr, please construct an array that could have been Bessie's original array. The values in your array should be in the range \[109,109]\[-10^9, 10^9].

입력

The first line contains NN.

Another NN lines follow. The iith of these lines contains the integers r_i,i,r_i,i+1,,r_i,Nr\_{i, i}, r\_{i, i + 1}, \ldots, r\_{i, N}.

It is guaranteed that there is some array aa with values in the range \[0,109]\[0, 10^9] such that for all iji \leq j, r_i,j=maxa\[ij]mina\[ij]r\_{i, j} = \max a\[i\ldots j] - \min a\[i\ldots j].

출력

Output one line containing NN integers b_1,b_2,,b_Nb\_1, b\_2, \ldots, b\_N in the range \[109,109]\[-10^9, 10^9] representing your array. They must satisfy r_i,j=maxb\[ij]minb\[ij]r\_{i, j} = \max b\[i\ldots j] - \min b\[i\ldots j] for all iji \leq j.