import sys readline = sys.stdin.readline read = sys.stdin.read n,k,*a = map(int,read().split()) print(max(a)-min(a))