n = int(input())

list1 = []

a = map(int, input().split())

for i in a:
    list1.append(i)

print(max(list1) - min(list1))