n = int(input())
input()
ni = [int(input()) for i in range(n)]
print(max(ni) - min(ni))