n, k = int(input()), int(input()) date = list(sorted(map(int,[input() for _ in range(n)]))) print(date[-1] - date[0])