N = input() K = input() A = [input() for _ in xrange(N)] print max(A) - min(A)