n=gets.to_i;gets
mx=mn=nil
n.times{
    u=gets.to_i
    mn=u if !mn||u<mn
    mx=u if !mx||mx<u
}
puts mx-mn