N = int(input())

min_v = int(input())
r = int(input())
max_v = r - min_v
if min_v > r:
    min_v = r

for _n in range(2, N):
    r = int(input())
    if max_v < r - min_v:
        max_v = r - min_v
    if min_v > r:
        min_v = r
print(max_v)
 N = int(input()) N int(input()) int input() input min_v = int(input()) min_v int(input()) int input() input r = int(input()) r int(input()) int input() input max_v = r - min_v max_v r - min_v r min_v if min_v > r:
    min_v = r min_v > r min_v r min_v = r min_v r for _n in range(2, N):
    r = int(input())
    if max_v < r - min_v:
        max_v = r - min_v
    if min_v > r:
        min_v = r _n range(2, N) range 2 N r = int(input()) r int(input()) int input() input if max_v < r - min_v:
        max_v = r - min_v
     max_v < r - min_v max_v r - min_v r min_v max_v = r - min_v max_v r - min_v r min_v if min_v > r:
        min_v = r min_v > r min_v r min_v = r min_v r print(max_v) print max_v max_v = r - min_v r - min_v max_v min_v = r r min_v min_v = int(input()) int(input()) min_v r = int(input()) int(input()) r N = int(input()) int(input()) N r = int(input()) int(input()) r max_v = r - min_v r - min_v max_v min_v = r r min_v
N = int(input())

min_v = int(input())
r = int(input())
max_v = r - min_v
if min_v > r:
    min_v = r

for _n in range(2, N):
    r = int(input())
    if max_v < r - min_v:
        max_v = r - min_v
    if min_v > r:
        min_v = r
print(max_v)

