import sys sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def main(): N = int(input()) K = int(input()) n = [int(input()) for _ in range(N)] print(max(n) - min(n)) if __name__ == '__main__': main()