# -*- coding: utf-8 -*-



N = int(eval(input()))

A = list(map(int, input().split()))



A.sort()

max_diff = A[N-1] - A[0]

print(max_diff)

# -*- coding: utf-8 -*-



N = int(eval(input()))

A = list(map(int, input().split()))



max_A = min_A = A[0]

for i in range(1,N,1):

    if A[i] > max_A:

        max_A = A[i]

    if A[i] < min_A:

        min_A = A[i]



max_diff = max_A - min_A

print(max_diff)

# -*- coding: utf-8 -*-
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
max_diff = A[N - 1] - A[0]
print(max_diff)

# -*- coding: utf-8 -*-
N = int(eval(input()))
A = list(map(int, input().split()))
max_A = min_A = A[0]
for i in range(1, N, 1):
    if A[i] > max_A:
        max_A = A[i]
    if A[i] < min_A:
        min_A = A[i]
max_diff = max_A - min_A
print(max_diff)

-A.sort() -max_diff = A[N - 1] - A[0] +max_A = min_A = A[0] +for i in range(1, N, 1): +    if A[i] > max_A: +        max_A = A[i] +    if A[i] < min_A: +        min_A = A[i] +max_diff = max_A - min_A