local n=io.read("n")
local a={}
for i=1,n do
    a[i]=io.read("n")-i
end
table.sort(a)

if n%2==1 then
    local median=a[n//2]
    local sadness=0
    for i=1,n do
        sadness=sadness+math.abs(a[i]-median)
    end
    print(sadness)
else
    local median1=a[n//2]
    local sadness1=0
    local median2=a[n//2-1]
    local sadness2=0
    for i=1,n do
        sadness1=sadness1+math.abs(a[i]-median1)
        sadness2=sadness2+math.abs(a[i]-median2)
    end
    print(math.min(sadness1,sadness2))
end