N = gets.to_i
K = gets.to_i
A = N.times.map{gets.to_i}

A.sort!
p A.max - A.min