res = -10 ** 9
n   = int(input())
a   = int(input())
Min = int(a)

for mak in range(n - 1) :
    tem = 0
    b = int(input())
    Min = min(b, Min)
    
    if   b < a : tem = b - a
    else       : tem = b - Min

    if tem > res : res = int(tem)
    a   = int(b)
print(res) res = -10 ** 9 res -10 ** 9 -10 9 n   = int(input()) n int(input()) int input() input a   = int(input()) a int(input()) int input() input Min = int(a) Min int(a) int a for mak in range(n - 1) :
    tem = 0
    b = int(input())
    Min = min(b, Min)
    
    if   b < a : tem = b - a
    else       : tem = b - Min

    if tem > res : res = int(tem)
    a   = int(b) mak range(n - 1) range n - 1 n 1 tem = 0 tem 0 b = int(input()) b int(input()) int input() input Min = min(b, Min) Min min(b, Min) min b Min if   b < a : tem = b - a
    else       : tem = b - Min

     b < a b a if tem > res : res = int(tem)
     tem > res tem res a   = int(b) a int(b) int b print(res) print res a   = int(input()) int(input()) a tem = 0 0 tem Min = min(b, Min) min(b, Min) Min b = int(input()) int(input()) b a   = int(b) int(b) a n   = int(input()) int(input()) n Min = int(a) int(a) Min res = -10 ** 9 -10 ** 9 res
res = -10 ** 9
n   = int(input())
a   = int(input())
Min = int(a)

for mak in range(n - 1) :
    tem = 0
    b = int(input())
    Min = min(b, Min)
    
    if   b < a : tem = b - a
    else       : tem = b - Min

    if tem > res : res = int(tem)
    a   = int(b)
print(res)