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