import math N = int(input()) K = int(input()) listn = [] for i in range(N): listn.append(int(input())) listn.sort() print(listn[N-1] - listn[0])