import Data.List
main::IO()
main=do
  nc<-getLine
  let n = read nc::Int
  datc<-getLine
  let dat = map read (words datc)::[Int]
  print ((head (sortBy (\x -> (\y -> compare y x )) dat))-(head (sortBy compare dat)))