import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # えっ? N,K,*A = map(int,read().split()) answer = max(A) - min(A) print(answer)