N = int(input()) #数字の数 K = [int(input())] #グループの数 n = [int(input()) for i in range(N)] #値 ans = max(n) - min(n) print(ans)