N =int(eval(input()))

R = []

for i in range(N):

        R.append(int(eval(input())))

maxv=-2000000000

minv=R[0]

for i in range(1,N):

    maxv=max(maxv,R[i]-minv)

    minv=min(minv,R[i])

print(maxv)
import sys

i=input

n =int(i())

r0=int(i())

r1=int(i())

maxv=r1-r0

minv=min(r1,r0)

for i in map(int,sys.stdin.readlines()):

    maxv=max(maxv,i-minv)

    minv=min(minv,i)

print(maxv)
N = int(eval(input()))
R = []
for i in range(N):
    R.append(int(eval(input())))
maxv = -2000000000
minv = R[0]
for i in range(1, N):
    maxv = max(maxv, R[i] - minv)
    minv = min(minv, R[i])
print(maxv)

import sys

i = input
n = int(i())
r0 = int(i())
r1 = int(i())
maxv = r1 - r0
minv = min(r1, r0)
for i in map(int, sys.stdin.readlines()):
    maxv = max(maxv, i - minv)
    minv = min(minv, i)
print(maxv)

-N = int(eval(input())) -R = [] -for i in range(N): -    R.append(int(eval(input()))) -maxv = -2000000000 -minv = R[0] -for i in range(1, N): -    maxv = max(maxv, R[i] - minv) -    minv = min(minv, R[i]) +import sys + +i = input +n = int(i()) +r0 = int(i()) +r1 = int(i()) +maxv = r1 - r0 +minv = min(r1, r0) +for i in map(int, sys.stdin.readlines()): +    maxv = max(maxv, i - minv) +    minv = min(minv, i)