n = int(input())
l = [int(input()) for _ in range(n)]

minval = l[0]
maxp = -1000000000
for val in l[1:]:
    if maxp < val - minval:
        maxp = val - minval
    if minval > val:
        minval = val

print(maxp)
 n = int(input()) n int(input()) int input() input int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input l = [int(input()) for _ in range(n)] l [int(input()) for _ in range(n)] minval = l[0] minval l[0] l 0 maxp = -1000000000 maxp -1000000000 for val in l[1:]:
    if maxp < val - minval:
        maxp = val - minval
    if minval > val:
        minval = val val l[1:] l 1: 1 if maxp < val - minval:
        maxp = val - minval
     maxp < val - minval maxp val - minval val minval maxp = val - minval maxp val - minval val minval if minval > val:
        minval = val minval > val minval val minval = val minval val print(maxp) print maxp minval = l[0] l[0] minval maxp = val - minval val - minval maxp n = int(input()) int(input()) n maxp = -1000000000 -1000000000 maxp l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l minval = val val minval
n = int(input())
l = [int(input()) for _ in range(n)]

minval = l[0]
maxp = -1000000000
for val in l[1:]:
    if maxp < val - minval:
        maxp = val - minval
    if minval > val:
        minval = val

print(maxp)

