n = int(input())
p = -10 ** 10
rmin= 10 ** 10
while n > 0:
    r = int(input())
    if n == 0:
        rmax = r
    else:
        if r - rmin > p:
            p = r - rmin
        if r < rmin:
            rmin = r
    n -= 1
print(p) n = int(input()) n int(input()) int input() input p = -10 ** 10 p -10 ** 10 -10 10 rmin= 10 ** 10 rmin 10 ** 10 10 10 while n > 0:
    r = int(input())
    if n == 0:
        rmax = r
    else:
        if r - rmin > p:
            p = r - rmin
        if r < rmin:
            rmin = r
    n -= 1 n > 0 n 0 r = int(input()) r int(input()) int input() input if n == 0:
        rmax = r
    else:
        if r - rmin > p:
            p = r - rmin
        if r < rmin:
            rmin = r
     n == 0 n 0 rmax = r rmax r if r - rmin > p:
            p = r - rmin
         r - rmin > p r - rmin r rmin p p = r - rmin p r - rmin r rmin if r < rmin:
            rmin = r
     r < rmin r rmin rmin = r rmin r n -= 1 n 1 print(p) print p r = int(input()) int(input()) r p = -10 ** 10 -10 ** 10 p rmax = r r rmax n = int(input()) int(input()) n rmin= 10 ** 10 10 ** 10 rmin n -= 1 1 n p = r - rmin r - rmin p rmin = r r rmin
n = int(input())
p = -10 ** 10
rmin= 10 ** 10
while n > 0:
    r = int(input())
    if n == 0:
        rmax = r
    else:
        if r - rmin > p:
            p = r - rmin
        if r < rmin:
            rmin = r
    n -= 1
print(p)