import Data.List

solver::[Int]->Int
solver ls = let l = length ls in
            case mod l 2 of
              0 -> let b = head (drop ((div l 2)-1) ls) in (sum.(map abs).(map (b-))) ls
              1 -> let b = head (drop (div l 2) ls)     in (sum.(map abs).(map (b-))) ls

preproc::[Int]->[Int]
preproc ls = sort (map (\(x,y)->(x-y)) (zip ls [1..]) )

main::IO()
main=do
  _<-getLine
  d<-getLine
  let dat= map read (words d)::[Int]
  (print.solver.preproc) dat
