def g(n): for _ in range(n): yield int(input()) N = int(input()) K = input() lst = list(g(N)) print(max(lst) - min(lst))