import sys

n = int(input())
r0 = int(input())
r1 = int(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 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 mx = r1-r0 mx r1-r0 r1 r0 mn = min(r1,r0) mn min(r1,r0) 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 i map(int,sys.stdin.readlines()) map int sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines if mx < i - mn:
        mx = i - mn
        if 0 > i-mn:
            mn = i
    elif mn > i:
        mn = i mx < i - mn mx i - mn i mn mx = i - mn mx i - mn i mn if 0 > i-mn:
            mn = i
     0 > i-mn 0 i-mn i mn mn = i mn i elif mn > i:
        mn = i mn > i mn i mn = i mn i print(mx) print mx r1 = int(input()) int(input()) r1 n = int(input()) int(input()) n mx = r1-r0 r1-r0 mx mn = i i mn mn = min(r1,r0) min(r1,r0) mn mn = i i mn mx = i - mn i - mn mx r0 = int(input()) int(input()) r0
import sys

n = int(input())
r0 = int(input())
r1 = int(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)