import           Control.Monad
import           Data.List

solve :: [Int] -> Int -> Int
solve t n = spl
  where
    subL = join $ forM [1..length t - 1] $ \x ->
      return $ (t !! (x - 1)) - (t !! x) :: [] Int
    spl = minimum . map (abs . sum) . filter ((==n-1) . length) $ subsequences subL

main :: IO ()
main = do
  _ : [n] <- map (read @Int) . words <$> getLine
  trees <- map (read @Int) . lines <$> getContents
  let trees' = sort trees
  putStr $ show $ solve trees' n
