n = int(eval(input()))

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

ans = 0

for i in range(len(a)):

    for j in range(i+1,len(a)):

        ans = max(ans,abs(a[i]-a[j]))

print(ans)
n = int(eval(input()))

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

ans = max(a)-min(a)

print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(len(a)):
    for j in range(i + 1, len(a)):
        ans = max(ans, abs(a[i] - a[j]))
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
ans = max(a) - min(a)
print(ans)

-ans = 0 -for i in range(len(a)): -    for j in range(i + 1, len(a)): -        ans = max(ans, abs(a[i] - a[j])) +ans = max(a) - min(a)