N = int(input()) K = input() N = [int(input()) for _ in range(N)] print(max(N) - min(N))