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