import sys

n = int(input())
r0 = int(input())
r1 = int(input())
p = r1 - r0
r = min(r0,r1)
for i in map(int, sys.stdin.readlines()):
    if p < i - r:
        p = i - r
    if r > i:
        r = i

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

n = int(input())
r0 = int(input())
r1 = int(input())
p = r1 - r0
r = min(r0,r1)
for i in map(int, sys.stdin.readlines()):
    if p < i - r:
        p = i - r
    if r > i:
        r = i

print(p)