import sys
l1 = input()
l2 = list(map(int,input().split()))
print(max(l2)-min(l2))