import Data.List
import Control.Applicative

main :: IO ()
main = do
    n <- readLn
    xs <- map read . words <$> getLine
    print $ solve n (flat xs)

flat :: [Int] -> [Int]
flat = zipWith (flip (-)) [1..]

solve :: Int -> [Int] -> Int
solve n xs
    | even n = min (sad' (ys !! (n `div` 2))) (sad' (ys !! (n `div` 2-1)))
    | odd n  = sad' (ys !! ((n-1) `div` 2))
        where ys = sort xs
              sad' = sad xs

sad :: [Int] -> Int -> Int
sad xs b = foldr (\x acc -> acc + abs (x-b)) 0 xs
