#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=500000+5;
const ll inf=0x7fffffff;
int n;
ll a[N],b[N];
int f[N],pre[N];
int p[N],cnt=0;
int main(){
freopen ("sequencec.in","r",stdin);
freopen ("sequencec.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;i++){
scanf("%lld",&a[i]);
b[i]=a[i]-i;f[i]=1;
}
int mxx=0,mxxi=0;
for (int i=1;i<=n;i++){
int mx=0,mxi=0;
for (int j=1;j<i;j++){
if (b[j]<=b[i]&&f[j]>mx){
mx=f[j];mxi=j;
}
}
f[i]=mx+1;
pre[i]=mxi;
if (f[i]>mxx)mxx=f[i],mxxi=i;
}
while(mxxi!=0){
p[++cnt]=mxxi;
mxxi=pre[mxxi];
}
printf("%d\n",n-cnt);
p[cnt+1]=0;p[0]=n+1;
b[0]=0;b[n+1]=inf;
ll ans=0;
for (int i=cnt+1;i>=1;i--){
int l=p[i],r=p[i-1];
ll mn=inf,now=0;
for (int j=l+1;j<=r-1;j++){
now+=abs(b[j]-b[r]);
}
mn=now;
for (int j=l+1;j<=r-1;j++){
now-=abs(b[j]-b[r]);
now+=abs(b[j]-b[l]);
mn=min(mn,now);
}
ans+=mn;
}
printf("%lld\n",ans);
return 0;
}