N=int(input()) K=int(input()) mi = 10**9 ma=-1 for _ in range(N): n = int(input()) mi = min(mi, n) ma = max(ma, n) print(ma-mi)