#include #include #include #include #include #include #include #include #include #include #include #include #define repeat(i,n) for (int i = 0; (i) < int(n); ++(i)) #define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i)) #define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i)) #define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i)) #define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) typedef long long ll; using namespace std; template void setmax(T & a, T const & b) { if (a < b) a = b; } template void setmin(T & a, T const & b) { if (b < a) a = b; } template auto vectors(X x, T a) { return vector(x, a); } template auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector(x, cont); } const int inf = 1e9+7; int main() { int n; cin >> n; vector s(n+1); repeat (i,n+1) cin >> s[i]; vector > dp = vectors(n+1, s[n]+1, inf); dp[0][0] = 1; repeat (i,n+1) { repeat (j,s[i]+1) { if (i >= 1) { setmin(dp[i][j], dp[i-1][j] + 1); } if (j >= 1) { repeat (a,j) { int b = j-a-1; setmin(dp[i][j], dp[i][a] + dp[i][b]); } } } } repeat (j,s[n]+1) { if (j) cout << ' '; cout << dp[n][j]; } cout << endl; return 0; }