import java.util.ArrayDeque; import java.util.Arrays; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); long[] A = new long[N + 1]; long[] S = new long[N + 1]; long[] a = new long[N + 1]; long[][] b = new long[N + 1][N + 1]; for (int i = 0; i < N; ++i) { A[i] = sc.nextLong(); } ++N; for (int i = 0; i < N; ++i) { S[i] = A[i] + (i > 0 ? S[i - 1] : 0); a[i] = -2 * S[i]; } for (int i = 0; i < N; ++i) { b[i][0] = S[i] * S[i] + (i > 0 ? S[i - 1] * S[i - 1] : 0); } long[][] dp = new long[N + 1][N + 1]; for (int i = 0; i < dp.length; ++i) { for (int j = 0; j < dp[i].length; ++j) { if (j == 0) { dp[i][j] = (i > 0 ? S[i - 1] * S[i - 1] : 0); } else { dp[i][j] = Long.MAX_VALUE / 3; } } } for (int D = 0; D < N; ++D) { long[] dq_a = new long[N]; long[] dq_b = new long[N]; Arrays.fill(dq_a, Long.MAX_VALUE / 3); Arrays.fill(dq_b, Long.MAX_VALUE / 3); int s = 0, t = 0; for (int i = 0; i < N; ++i) { int j = (i + 1) - (D + 1); if (j < 0 || j > i + 1) continue; long dq_a0 = a[i]; long dq_b0 = b[i][D]; // a1x+b1=a2x+b2 // a0-a1<0 // invalid な 条件 // x=-(b0-b1)/(a0-a1)<-(b2-b1)/(a2-a1) // (b0-b1)(a2-a1)>(b2-b1)(a0-a1) while (t - s >= 2 && (dq_b0 - dq_b[t - 1]) * (dq_a[t - 2] - dq_a[t - 1]) >= (dq_b[t - 2] - dq_b[t - 1]) * (dq_a0 - dq_a[t - 1])) { --t; } dq_a[t] = dq_a0; dq_b[t] = dq_b0; ++t; if (t - s >= 2 && dq_a[s] * S[i] + dq_b[s] >= dq_a[s + 1] * S[i] + dq_b[s + 1]) { ++s; } if (i + 1 < N) { dp[i + 1][D + 1] = S[i] * S[i] + dq_a[s] * S[i] + dq_b[s]; if (D + 1 < N) { b[i + 1][D + 1] = S[i + 1] * S[i + 1] + dp[i + 1][D + 1]; } } } } long[] ans = new long[N + 1]; Arrays.fill(ans, Long.MAX_VALUE / 3); for (int j = 1; j < N; ++j) { int D = (N - 1) - j; ans[j] = dp[N - 1][D];// dp[N-1][N-1] System.out.println(ans[j]); } } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }