function median(list)
  table.sort(list)
  local center = math.floor(#list / 2)
  if #list % 2 == 0 then
    return (list[center] + list[center + 1]) / 2
  else
    return list[center + 1]
  end
end

function sad(A, b)
  local acc = 0
  for i, v in ipairs(A) do
    acc = acc + math.abs(v - (b + i))
  end
  return acc
end

local N = tonumber(io.read())
local A = {}
for n in io.read():gmatch('%d+') do
  table.insert(A, tonumber(n))
end

local B = {}
for i, v in ipairs(A) do
  table.insert(B, (v - i))
end

io.write(sad(A, median(B)))
