SP1644 TREEOI14 - Trees

Description

Byteasar has a cottage. Lately, he has bought n trees and had them planted all in one row. Byteasar does not, however, like the order which the trees have been planted in. It particularly annoys him that tall and short ones have been mixed up, and the composition does not meet his aesthetic criteria. Byteasar has invented a _disorder coefficient_ so as to allow the gardener to comprehend his intentions: the lower the value of the coefficient the prettier the row of trees. It is defined in the following way: |h $ _{1} $ −h $ _{2} $ |+ |h $ _{2} $ −h $ _{3} $ |+...+|h $ _{n−1} $ −h $ _{n} $ |, where h $ _{1} $ ,h $ _{2} $ , . . . ,h $ _{n} $ are the heights of consecutive trees in a row. Replanting is a very toilsome and cumbersome task, therefore Byteasar has ordered the gardener to replant two trees at the most (i.e. interchange their positions). The task of the gardener is to choose the pair to replant in a way that makes the disorder coefficient the smallest. The gardener is not sure if he has chosen the correct pair of trees and he fears he may lose his job if he is mistaken. Help him: for each tree calculate the minimal disorder coefficient that may be attained by switching places with any other tree. ### Task Write a program which: - reads the height of the consecutive trees in a row from the standard input, - for each tree calculates the minimal disorder coefficient that may be attained should it switch places with some other tree (or should there be no change at all), - writes the outcome to the standard output.

Input Format

The first line of the standard input contains one integer _n_ (2

Output Format

The output should consist of precisely _n_ lines. The i-th line should contain a single integer - the smallest disorder coefficient attainable when considering replanting of the i-th tree.