N = int(input())
max_p = -1145148101919
min_v = int(input())
for i in range(1, N):
    R = int(input())
    max_p = max(R - min_v, max_p)
    min_v = min(R, min_v)

print(max_p) N = int(input()) N int(input()) int input() input max_p = -1145148101919 max_p -1145148101919 min_v = int(input()) min_v int(input()) int input() input for i in range(1, N):
    R = int(input())
    max_p = max(R - min_v, max_p)
    min_v = min(R, min_v) i range(1, N) range 1 N R = int(input()) R int(input()) int input() input max_p = max(R - min_v, max_p) max_p max(R - min_v, max_p) max R - min_v R min_v max_p min_v = min(R, min_v) min_v min(R, min_v) min R min_v print(max_p) print max_p N = int(input()) int(input()) N min_v = int(input()) int(input()) min_v R = int(input()) int(input()) R max_p = max(R - min_v, max_p) max(R - min_v, max_p) max_p max_p = -1145148101919 -1145148101919 max_p min_v = min(R, min_v) min(R, min_v) min_v
N = int(input())
max_p = -1145148101919
min_v = int(input())
for i in range(1, N):
    R = int(input())
    max_p = max(R - min_v, max_p)
    min_v = min(R, min_v)

print(max_p)