n = int(input())
a = int(input())
b = int(input())

interest = b - a
min = min(a,b)
for i in range(n-2):
    f = int(input())
    if f - min > interest:
        interest = f - min
    elif f < min:
        min = f
print(interest) n = int(input()) n int(input()) int input() input a = int(input()) a int(input()) int input() input b = int(input()) b int(input()) int input() input interest = b - a interest b - a b a min = min(a,b) min min(a,b) min a b for i in range(n-2):
    f = int(input())
    if f - min > interest:
        interest = f - min
    elif f < min:
        min = f i range(n-2) range n-2 n 2 f = int(input()) f int(input()) int input() input if f - min > interest:
        interest = f - min
    elif f < min:
        min = f f - min > interest f - min f min interest interest = f - min interest f - min f min elif f < min:
        min = f f < min f min min = f min f print(interest) print interest b = int(input()) int(input()) b a = int(input()) int(input()) a min = f f min n = int(input()) int(input()) n f = int(input()) int(input()) f interest = f - min f - min interest min = min(a,b) min(a,b) min interest = b - a b - a interest
n = int(input())
a = int(input())
b = int(input())

interest = b - a
min = min(a,b)
for i in range(n-2):
    f = int(input())
    if f - min > interest:
        interest = f - min
    elif f < min:
        min = f
print(interest)