#include <iostream>
using namespace std;
using ll = long long;
const ll INF = 1e18;

int main() {
    int N;
    cin >> N;
    ll S[N + 1], DP[N + 2][N + 1];
    S[0] = 0;
    for (int i = 0; i < N; i++) cin >> S[i + 1], S[i + 1] += S[i];
    for (int i = 0; i < N + 2; i++) {
        for (int j = 0; j < N + 1; j++) DP[i][j] = INF;
    }
    DP[0][0] = 0;
    for (int i = 0; i < N + 1; i++) {
        for (int j = 0; j < N + 1; j++) {
            for (int k = 0; k < N + 2; k++) {
                if (i - k < 0 || j - k < 0) continue;
                ll cost = S[i] - S[i - k];
                DP[i + 1][j] = min(DP[i + 1][j], DP[i - k][j - k] + cost * cost);
            }
        }
    }
    for (int i = 0; i < N; i++) {
        cout << DP[N + 1][i + 1] << endl;
    }
}