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