local n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n") - i
end
table.sort(a)
local hn = n // 2
local pos = a[hn]
local ret = 0
for i = 1, hn do
  ret = ret + pos - a[i]
end
for i = hn + 1, n do
  ret = ret + a[i] - pos
end
print(ret)
