N = gets.to_i
K = gets.to_i
n = []
N.times do
  n.push(gets.to_i)
end

n.sort!
puts (n[N-1] - n[0])