N=int(raw_input()) K=int(raw_input()) maxVal =0 minVal = 10000 for i in range(N): n = int(raw_input()) minVal = min(minVal,n) maxVal = max(maxVal,n) print maxVal-minVal