import sys input = sys.stdin.readline from collections import * class ConvexHullTrick: def __init__(self, getmin=1, a_inc=0, x_inc=1): self.getmin = getmin self.a_inc = a_inc self.x_inc = x_inc self.ab = deque() self.inf = (1 << 63)-1 self.px = self.inf*(-2*x_inc+1) def add_line(self, a, b): if not self.ab: self.ab.append((a, b)) return if self.getmin ^ self.a_inc: if self.ab and a == self.ab[-1][0]: if (b-self.ab[-1][1])*(self.getmin*2-1) >= 0: return self.ab.pop() if self.x_inc: while len(self.ab) > 1: c, d = self.ab.pop() e, f = self.ab[-1] if (b-d)*(e-c) > (d-f)*(c-a): self.ab.append((c, d)) break else: (c, d), x = self.ab[-1], self.px if (a*x+b-c*x-d)*(self.getmin*2-1) >= 0: return self.ab.append((a, b)) else: if self.ab and a == self.ab[0][0]: if (b-self.ab[0][1])*(self.getmin*2-1) >= 0: return self.ab.popleft() if not self.x_inc: while len(self.ab) > 1: c, d = self.ab.popleft() e, f = self.ab[0] if (b-d)*(e-c) < (d-f)*(c-a): self.ab.append((c, d)) break else: (c, d), x = self.ab[0], self.px if (a*x+b-c*x-d)*(self.getmin*2-1) >= 0: return self.ab.appendleft((a, b)) def __getitem__(self, x): self.px = x if not self.ab: return self.inf*(self.getmin*2-1) if self.x_inc: while len(self.ab) > 1: a, b = self.ab.popleft() c, d = self.ab[0] if (a*x+b-c*x-d)*(self.getmin*2-1) < 0: self.ab.appendleft((a, b)) return a*x+b else: while len(self.ab) > 1: a, b = self.ab.pop() c, d = self.ab[-1] if (a*x+b-c*x-d)*(self.getmin*2-1) < 0: self.ab.append((a, b)) return a*x+b a, b = self.ab[0] return a*x+b class CHT: #傾きの単調性と最小値クエリのxの単調性を仮定 def __init__(self): self.q = deque([]) #直線群 def f(self, f1, x): #直線f1のxの値 return f1[0]*x+f1[1] def check(self, f1, f2, f3): #f2を削除しても良いかの判定 return (f2[0]-f1[0])*(f3[1]-f2[1])>=(f2[1]-f1[1])*(f3[0]-f2[0]) def add_line(self, a, b): #傾きa, 切片bの直線を追加 while len(self.q)>=2 and self.check(self.q[-2], self.q[-1], (a, b)): self.q.pop() self.q.append((a, b)) def get(self, x): #xでの最小値 while len(self.q)>=2 and self.f(self.q[0], x)>=self.f(self.q[1], x): self.q.popleft() return self.f(self.q[0], x) def dfs(l, r): # [l, r) global ans if r-l==1: ans[l] = min(ans[l], 1+A[l]) return m = (l+r)//2 # [l, m) cht = ConvexHullTrick() left = defaultdict(lambda: 10**18) for i in range(m+1, r+1): cht.add_line(-2*i, i*i+acc[i]) for i in range(l, m): left[i] = cht[i]+i*i-acc[i] left[i] = min(left[i], left[i-1]) # [m, r) cht = ConvexHullTrick() right = defaultdict(lambda: 10**18) for i in range(l, m+1): cht.add_line(-2*i, i*i-acc[i]) for i in range(r, m, -1): right[i] = cht[i]+i*i+acc[i] right[i] = min(right[i], right[i+1]) for i in range(l, r): ans[i] = min(ans[i], left[i], right[i+1]) dfs(l, m) dfs(m, r) N = int(input()) A = list(map(int, input().split())) acc = [0] for Ai in A: acc.append(acc[-1]+Ai) ans = [10**18]*N dfs(0, N) for i in range(N): print(ans[i])