import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Maybe

readInt = fst . fromJust . B.readInt

main = do
 n <- readLn
 xys <- map (map readInt . B.words) . B.lines <$> B.getContents
 let xs = sort (map head xys)
 let ys = sort (map last xys)
 print (built n xs ys)

built n xs ys
 | odd n = sum (take (div n 2) dxs) + sum (take (div n 2) dys)
 | otherwise = sum (take (div n 2) dxs) + sum (take (div n 2) dys) - 2
 where
  dxs = sort (zipWith (-) (tail xs) xs)
  dys = sort (zipWith (-) (tail ys) ys)