f = lambda: int(eval(input()))

d = -float('inf')

n = f()

l = f()

for _ in range(n-1):

	r = f()

	d = max(d, r-l)

	l = min(l, r)

print(d)

import sys

d = -float('inf')

n = int(eval(input()))

l = int(eval(input()))

for s in sys.stdin:

	r = int(s)

	d = max(d, r-l)

	l = min(l, r)

print(d)

f = lambda: int(eval(input()))
d = -float("inf")
n = f()
l = f()
for _ in range(n - 1):
    r = f()
    d = max(d, r - l)
    l = min(l, r)
print(d)

import sys

d = -float("inf")
n = int(eval(input()))
l = int(eval(input()))
for s in sys.stdin:
    r = int(s)
    d = max(d, r - l)
    l = min(l, r)
print(d)

-f = lambda: int(eval(input())) +import sys + -n = f() -l = f() -for _ in range(n - 1): -    r = f() +n = int(eval(input())) +l = int(eval(input())) +for s in sys.stdin: +    r = int(s)