def main(): n = int(input()) k = int(input()) list = [] list = [int(input()) for i in range(n)] list.sort() ans = list[n - 1] - list[0] print(ans) if __name__ == "__main__": main()