n = int(input())
houses = [int(x) for x in input().split()]
houses.sort()
t = []
ans = 0
for i in range(1,n):
    t.append(houses[i])
    if houses.count(houses[i]) >= 2:
        pass
    else:
        ans += houses[i] - houses[i-1]
        ans = abs(ans)
print(ans)