n = int(input()) k = int(input()) s = 1000 b = 0 for _ in n: c = int(input()) s = min(c,s) b = max(c,b) print(b-s)