solver::[Int]->Int
solver ls = max ((maximum ls) - (minimum ls)) (abs ((minimum ls) - (maximum ls)))

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