package no266; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] s = new int[n+1]; for(int i=0;i<=n;i++) { s[i] = sc.nextInt(); } int[][] dp = new int[n+1][11]; for(int i=0;i<=n;i++) { Arrays.fill(dp[i], 1 << 29); } dp[0][0] = 1; for(int i=0;i<=n;i++) { for(int j=0;j<=s[i];j++) { if (j > 0) { int[][] dp2 = new int[3][j]; for(int k=0;k<3;k++) { Arrays.fill(dp2[k], 1 << 29); } dp2[0][0] = 0; dp2[1][0] = dp[i][0]; dp2[2][0] = dp[i][0] * 2; for(int k=1;k 0) { dp[i][j] = Math.min(dp[i][j], dp[i-1][j] + 1); } } } // System.out.println(Arrays.deepToString(dp)); StringBuilder sb = new StringBuilder(); for(int i=0;i<=s[n];i++) { if (i > 0) { sb.append(' '); } sb.append(dp[n][i]); } System.out.println(sb); } }