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