import java.util.Scanner; public class Yuki_596 { public Yuki_596() { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int[] S = new int[N + 1]; for (int i = 0; i <= N; i++) { S[i] = scanner.nextInt(); } int T = S[S.length - 1] + 1; int[][] dp = new int[N + 1][T]; for (int i = 1; i <= N; i++) { dp[i][0] = i + 1; } for (int i = 0; i <= S[0]; i++) { dp[0][i] = i + 1; } for (int i = 1; i <= N; i++) { for (int j = 1; j <= T; j++) { if (j > S[i]) { continue; } dp[i][j] = dp[i][0] + dp[i][j - 1]; for (int k = 0; k < j; k++) { dp[i][j] = Math.min(dp[i][j], dp[i][k] + dp[i][j - k - 1]); } if (dp[i - 1][j] > 0) { dp[i][j] = Math.min(dp[i][j], dp[i - 1][j] + 1); } } } for (int i = 0; i < T; i++) { if (i >= 1) { System.out.print(" "); } System.out.print(dp[N][i]); } } public static void main(String[] args) { Yuki_596 hoge = new Yuki_596(); } }