N = int(input()) K = int(input()) S = [input() for i in range(2,N+2)] M = [int(i) for i in S] T = sorted(M) U = T[N-1]-T[0] print(U)