n = int(input())

t = []

for i in range(n):
    t.append(int(input()))

buy = t[0]
val = t[-1] - buy

for i in range(1, n):
    if t[i] - buy > val:
        val = t[i] - buy
    if t[i] < buy:
        buy = t[i]

print(val)
 n = int(input()) n int(input()) int input() input t = [] t [] for i in range(n):
    t.append(int(input())) i range(n) range n t.append(int(input())) t.append t append int(input()) int input() input buy = t[0] buy t[0] t 0 val = t[-1] - buy val t[-1] - buy t[-1] t -1 buy for i in range(1, n):
    if t[i] - buy > val:
        val = t[i] - buy
    if t[i] < buy:
        buy = t[i] i range(1, n) range 1 n if t[i] - buy > val:
        val = t[i] - buy
     t[i] - buy > val t[i] - buy t[i] t i buy val val = t[i] - buy val t[i] - buy t[i] t i buy if t[i] < buy:
        buy = t[i] t[i] < buy t[i] t i buy buy = t[i] buy t[i] t i print(val) print val buy = t[0] t[0] buy buy = t[i] t[i] buy n = int(input()) int(input()) n val = t[i] - buy t[i] - buy val t = [] [] t val = t[-1] - buy t[-1] - buy val
n = int(input())

t = []

for i in range(n):
    t.append(int(input()))

buy = t[0]
val = t[-1] - buy

for i in range(1, n):
    if t[i] - buy > val:
        val = t[i] - buy
    if t[i] < buy:
        buy = t[i]

print(val)

