def max_profit(A, n):
    minv = A[0]
    for j in range(1, n):
        if j == 1:
            maxv = A[j] - A[j-1]
        if maxv < A[j] - minv:
            maxv = A[j] - minv
        if minv > A[j]:
            minv = A[j]
    print(maxv)

n=int(input())
A=[int(input()) for i in range(n)]

max_profit(A, n) def max_profit(A, n):
    minv = A[0]
    for j in range(1, n):
        if j == 1:
            maxv = A[j] - A[j-1]
        if maxv < A[j] - minv:
            maxv = A[j] - minv
        if minv > A[j]:
            minv = A[j]
    print(maxv) max_profit minv = A[0] minv A[0] A 0 for j in range(1, n):
        if j == 1:
            maxv = A[j] - A[j-1]
        if maxv < A[j] - minv:
            maxv = A[j] - minv
        if minv > A[j]:
            minv = A[j]
     j range(1, n) range 1 n if j == 1:
            maxv = A[j] - A[j-1]
         j == 1 j 1 maxv = A[j] - A[j-1] maxv A[j] - A[j-1] A[j] A j A[j-1] A j-1 j 1 if maxv < A[j] - minv:
            maxv = A[j] - minv
         maxv < A[j] - minv maxv A[j] - minv A[j] A j minv maxv = A[j] - minv maxv A[j] - minv A[j] A j minv if minv > A[j]:
            minv = A[j]
     minv > A[j] minv A[j] A j minv = A[j] minv A[j] A j print(maxv) print maxv A A n n n=int(input()) n int(input()) int input() input int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input A=[int(input()) for i in range(n)] A [int(input()) for i in range(n)] max_profit(A, n) max_profit A n n=int(input()) int(input()) n A=[int(input()) for i in range(n)] [int(input()) for i in range(n)] A def max_profit(A, n):
    minv = A[0]
    for j in range(1, n):
        if j == 1:
            maxv = A[j] - A[j-1]
        if maxv < A[j] - minv:
            maxv = A[j] - minv
        if minv > A[j]:
            minv = A[j]
    print(maxv) def max_profit(A, n):
    minv = A[0]
    for j in range(1, n):
        if j == 1:
            maxv = A[j] - A[j-1]
        if maxv < A[j] - minv:
            maxv = A[j] - minv
        if minv > A[j]:
            minv = A[j]
    print(maxv) max_profit
def max_profit(A, n):
    minv = A[0]
    for j in range(1, n):
        if j == 1:
            maxv = A[j] - A[j-1]
        if maxv < A[j] - minv:
            maxv = A[j] - minv
        if minv > A[j]:
            minv = A[j]
    print(maxv)

n=int(input())
A=[int(input()) for i in range(n)]

max_profit(A, n)
