n = int(input())

min = float('inf')
max_diff = -float('inf')

for _ in range(n):
    i = int(input())

    if max_diff < i - min:
        max_diff = i - min

    if i < min:
        min = i

print(max_diff) n = int(input()) n int(input()) int input() input min = float('inf') min float('inf') float 'inf' max_diff = -float('inf') max_diff -float('inf') float('inf') float 'inf' for _ in range(n):
    i = int(input())

    if max_diff < i - min:
        max_diff = i - min

    if i < min:
        min = i _ range(n) range n i = int(input()) i int(input()) int input() input if max_diff < i - min:
        max_diff = i - min

     max_diff < i - min max_diff i - min i min max_diff = i - min max_diff i - min i min if i < min:
        min = i i < min i min min = i min i print(max_diff) print max_diff n = int(input()) int(input()) n max_diff = -float('inf') -float('inf') max_diff min = float('inf') float('inf') min i = int(input()) int(input()) i min = i i min max_diff = i - min i - min max_diff
n = int(input())

min = float('inf')
max_diff = -float('inf')

for _ in range(n):
    i = int(input())

    if max_diff < i - min:
        max_diff = i - min

    if i < min:
        min = i

print(max_diff)