import sys

 

n = int(eval(input()))

r0 = int(eval(input()))

r1 = int(eval(input()))

mx = r1-r0

mn = min(r1,r0)

 

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

    if mx < i - mn:

        mx = i - mn

    if mn > i:

        mn = i

 

print(mx)
import sys



n = int(eval(input()))

r0 = int(eval(input()))

r1 = int(eval(input()))

mx = r1-r0

mn = min(r1,r0)



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

    if mx < i - mn:

        mx = i - mn

        if 0 > i-mn:

            mn = i

    elif mn > i:

        mn = i



print(mx)
import sys

n = int(eval(input()))
r0 = int(eval(input()))
r1 = int(eval(input()))
mx = r1 - r0
mn = min(r1, r0)
for i in map(int, sys.stdin.readlines()):
    if mx < i - mn:
        mx = i - mn
    if mn > i:
        mn = i
print(mx)

import sys

n = int(eval(input()))
r0 = int(eval(input()))
r1 = int(eval(input()))
mx = r1 - r0
mn = min(r1, r0)
for i in map(int, sys.stdin.readlines()):
    if mx < i - mn:
        mx = i - mn
        if 0 > i - mn:
            mn = i
    elif mn > i:
        mn = i
print(mx)

-    if mn > i: +        if 0 > i - mn: +            mn = i +    elif mn > i: