class Calc0021 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @n = args.shift.first.to_i @k = args.shift.first.to_i @ns = args.map(&:first).map(&:to_i) end def run ns = @ns.sort ns.last - ns.first end end puts Calc0021.new(STDIN.readlines).run if __FILE__ == $0