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