import sys
n = int(input())
a = list(map(int,input().split()))
x = max(a)
y = min(a)
print(x-y)