def main(): N = int(input()) K = int(input()) I = tuple(int(input()) for _ in range(N)) ans = max(I) - min(I) print(ans) main()