Welcome to Innopolis city. Throughout the whole year, Innopolis citizens suffer from everlasting city construction.

From the window in your room, you see the sequence of n hills, where i-th of them has height ai. The Innopolis administration wants to build some houses on the hills. However, for the sake of city appearance, a house can be only built on the hill, which is strictly higher than neighbouring hills (if they are present). For example, if the sequence of heights is 5, 4, 6, 2, then houses could be built on hills with heights 5 and 6 only.

The Innopolis administration has an excavator, that can decrease the height of an arbitrary hill by one in one hour. The excavator can only work on one hill at a time. It is allowed to decrease hills up to zero height, or even to negative values. Increasing height of any hill is impossible. The city administration wants to build k houses, so there must be at least k hills that satisfy the condition above. What is the minimum time required to adjust the hills to achieve the administration's plan?

However, the exact value of k is not yet determined, so could you please calculate answers for all k in range ? Here denotes n divided by two, rounded up.

Input

The first line of input contains the only integer n (1 ≤ n ≤ 5000)—the number of the hills in the sequence.

Second line contains n integers ai (1 ≤ ai ≤ 100 000)—the heights of the hills in the sequence.

Output

Print exactly numbers separated by spaces. The i-th printed number should be equal to the minimum number of hours required to level hills so it becomes possible to build i houses.

Examples

Input

5
1 1 1 1 1

Output

1 2 2 

Input

3
1 2 3

Output

0 2 

Input

5
1 2 3 2 2

Output

0 1 3 

Note

In the first example, to get at least one hill suitable for construction, one can decrease the second hill by one in one hour, then the sequence of heights becomes 1, 0, 1, 1, 1 and the first hill becomes suitable for construction.

In the first example, to get at least two or at least three suitable hills, one can decrease the second and the fourth hills, then the sequence of heights becomes 1, 0, 1, 0, 1, and hills 1, 3, 5 become suitable for construction.

 

开始想设二维dp,f(i,j)表示前i个山丘建j个房子的最小代价。但是没办法转移,状态之间互相影响。

正解:

设f(i,j,1):前i个山丘,建了j个房子,并且第i个山丘建房子

f(i,j,0):前i个山丘,建了j个房子,并且第i个山丘不建房子,即使这个位置不需代价就可以建房子。

需要注意的一点是:如果一个位置建了房子,那么它的相邻位置就不能建了,因为房子高度严格大于两边。

f[i][j][0]=min(f[i-1][j][0],f[i-1][j][1]),f[i][j][1]由f[i-2][j-1][0]和f[i-2][j-1][1]组成的式子转移而来,见代码。

边界f(i,0,1)=∞,f(0,_,_)=∞,f[1][1][1]=max(0,h[2]-h[1]+1), f[0][0][0]=f[1][0][0]=0
  

注意每一个状态都要精确地表示。

这题代码非常恶心。

#include<bits/stdc++.h>
using namespace std;

int n,h[5010],f[5010][(5010>>1)+1][2];

int temp1(int i,int j)
{
	int ret=f[i-2][j-1][0];
	if(h[i-1]>=h[i])ret+=h[i-1]-h[i]+1;
	if(h[i+1]>=h[i])ret+=h[i+1]-h[i]+1;
	return ret;
}

int temp2(int i,int j)
{
	int ret=f[i-2][j-1][1];
	if(h[i+1]>=h[i])ret+=h[i+1]-h[i]+1;  //右边一定需要 
	if(h[i]<h[i-2] && h[i-1]>=h[i])ret+=max(0,min(h[i-2]-1,h[i-1])-h[i]+1);
	return ret; //左边:因为i-2建了房子,所以,i-1处的工程量包含在了f(i-2)里,i-1一定比i-2低 
}              //如果i比i-2高,一定比i-1高。否则,如果i-1比i低也没问题。否则,i-1要处理到比i低 

int main()
{
//	freopen("input.in","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>h[i];
	for(int i=0;i<=1;i++)for(int j=0;j<=(n>>1)+1;j++)f[i][j][0]=f[i][j][1]=(1<<30);
	f[1][1][1]=max(0,h[2]-h[1]+1);
	f[0][0][0]=f[1][0][0]=0;
	for(int i=0;i<n;i++)f[i][0][1]=(1<<30);
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=(n>>1)+1;j++)
		{ 
			f[i][j][0]=min(f[i-1][j][0],f[i-1][j][1]);
			f[i][j][1]=min(temp1(i,j),temp2(i,j));
		}
	}
	for(int i=1;i<=ceil((n*1.0/2));i++)cout<<min(f[n][i][0],f[n][i][1])<<" ";
/*	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=(n>>1)+1;j++)
		{
			printf("  f(%d,%d,%d)=%d",i,j,0,f[i][j][0]);
			printf("  f(%d,%d,%d)=%d",i,j,1,f[i][j][1]);
		}
		puts("");
	}
*/	return 0;
}