#include using namespace std; using ll = long long; constexpr ll INF = 1e18; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } vector< vector > dp(n + 1, vector(n + 1, INF)); dp[0][0] = 0; { ll sum = 0; for (int i = 0; i < n; ++i) { sum += a[i]; dp[i + 1][i + 1] = sum * sum; } } for (int i = 0; i < n; ++i) { for (int j = 0; j <= i; ++j) { if (dp[i][j] >= INF) continue; int lim = min(n - j, n - 1 - i); ll sum = 0; for (int k = 1; k <= lim; ++k) { sum += a[i + k]; dp[i + 1 + k][j + k] = min(dp[i + 1 + k][j + k], dp[i][j] + sum * sum); } } } for (int k = 1; k <= n; ++k) { ll ans = INF; for (int i = k; i <= n; ++i) { ans = min(ans, dp[i][k]); } cout << ans << "\n"; } return 0; }