N = input() K = input() numbers = [input() for loop in xrange(N)] numbers.sort() ans = numbers[-1] - numbers[0] print ans