n = int(input())


ans = float("-INF")
min_v = int(input())
for _ in range(n-1):
    r = int(input())
    ans = max(ans, r - min_v)
    min_v = min(min_v, r)


print(ans) n = int(input()) n int(input()) int input() input ans = float("-INF") ans float("-INF") float "-INF" min_v = int(input()) min_v int(input()) int input() input for _ in range(n-1):
    r = int(input())
    ans = max(ans, r - min_v)
    min_v = min(min_v, r) _ range(n-1) range n-1 n 1 r = int(input()) r int(input()) int input() input ans = max(ans, r - min_v) ans max(ans, r - min_v) max ans r - min_v r min_v min_v = min(min_v, r) min_v min(min_v, r) min min_v r print(ans) print ans min_v = min(min_v, r) min(min_v, r) min_v r = int(input()) int(input()) r min_v = int(input()) int(input()) min_v ans = max(ans, r - min_v) max(ans, r - min_v) ans n = int(input()) int(input()) n ans = float("-INF") float("-INF") ans
n = int(input())


ans = float("-INF")
min_v = int(input())
for _ in range(n-1):
    r = int(input())
    ans = max(ans, r - min_v)
    min_v = min(min_v, r)


print(ans)
