#ALDS1_1_D

N = int(input())

min,dif = 10000000000, -10000000000

for i in range(N):
    a = int(input())
    if (a - min) > dif:
        dif = a - min
    if a < min:
        min = a
print(dif)
 N = int(input()) N int(input()) int input() input min,dif = 10000000000, -10000000000 min 10000000000 dif -10000000000 for i in range(N):
    a = int(input())
    if (a - min) > dif:
        dif = a - min
    if a < min:
        min = a i range(N) range N a = int(input()) a int(input()) int input() input if (a - min) > dif:
        dif = a - min
     (a - min) > dif a - min a min dif dif = a - min dif a - min a min if a < min:
        min = a a < min a min min = a min a print(dif) print dif min,dif = 10000000000, -10000000000 10000000000 min dif = 10000000000, -10000000000 -10000000000 dif a = int(input()) int(input()) a min = a a min N = int(input()) int(input()) N dif = a - min a - min dif
#ALDS1_1_D

N = int(input())

min,dif = 10000000000, -10000000000

for i in range(N):
    a = int(input())
    if (a - min) > dif:
        dif = a - min
    if a < min:
        min = a
print(dif)

