Beacon towers are built throughout and alongside the Great Wall. There was once a time when there were $n$ beacon towers built from west to east for defending against the invaders. The altitude of the $i$-th beacon tower, based on historical records, is $a_i$.
The defenders divide strategically all beacon towers into $k$ parts where each part contains several, but at least one, consecutive beacon towers. The scale of an individual part is given by the difference between the highest and the lowest altitudes of beacon towers, and the most sensible partition maximizes the sum of scales of all parts.
As a historian, you are dying to know the maximum sums of scales for every $k=1,2,\cdots,n$.
输入格式
The first line contains an integer $n\ (1\le n\le 10^4)$, denoting the number of beacon towers alongside the Great Wall.
The second line contains $n$ integers $a_1,a_2,\cdots,a_n$, where the $i$-th integer $a_i\ (1\le a_i\le 10^5)$ is the altitude of the $i$-th beacon tower.
输出格式
Output $n$ lines, the $i$-th of which contains an integer indicating the maximum sum for $k=i$.
样例输入 #1
5
1 2 3 4 5
样例输出 #1
4
3
2
1
0
样例输入 #2
5
1 2 1 2 1
样例输出 #2
1
2
2
1
0
来源
The 2020 ICPC Asia Yinchuan Regional Programming Contest