#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
while(ch<='9'&&ch>='0'){x=x*10+ch-48;ch=getchar();}
return x*f;
}
const int maxn=5e5+10;
int a[maxn];
int f[maxn];
struct node{
int l,r,id;
}p[maxn*2];
int top,he;
double w(int j,int i){
if(i<j) return -10000000;
else return double(a[j])+sqrt(i-j);
}
int binary(int x){
int l=p[top].l,r=p[top].r;
int y=p[top].id;
int ans=r;
while(l<=r){
int mid=(l+r)>>1;
if(w(y,mid)<=w(x,mid)) ans=mid,r=mid-1;
else l=mid+1;
}
return ans;
}
void work(int n){
for(int i=1;i<=n;i++){
while(top&&w(p[top].id,p[top].l)<=w(i,p[top].l))top--;
if(!top) p[++top]={i,n,i};
else if(w(p[top].id,p[top].r)>=w(i,p[top].r)) goto genshin;
else {
int res=binary(i);
p[top].r=res-1;
p[++top]={res,n,i};
}
genshin: if(he<=top&&p[he].r<i)he++;
f[i]=max(f[i],(long long)(ceil(w(p[he].id,i))));
}
}
signed main(){
int n=read();
for(int i=1;i<=n;i++){
a[i]=read();
}
he=1;
work(n);
for(int i=1;i<=n/2;i++)swap(a[i],a[n-i+1]),swap(f[i],f[n-i+1]);
top=he=0;
work(n);
for(int i=n;i>=1;i--) cout<<f[i]-a[i]<<'\n';
}
所有提交记录均没有类似错误...