n = io.read("*n")
t = {}
for i = 1, n do
  t[i] = io.read("*n") - i
end
table.sort(t)
mid = n % 2 == 0 and n / 2 or (n + 1) / 2
midval = t[mid]
sum = 0
for i = 1, n do
  sum = sum + math.abs(t[i] - midval)
end
print(sum)
