n = int(input())
R = [int(input()) for i in range(n)]

minv = float('inf')
maxv = -float('inf')
for r in R:
    maxv = max(maxv, r-minv)
    minv = min(minv, r)
print(maxv) n = int(input()) n int(input()) int input() input int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input R = [int(input()) for i in range(n)] R [int(input()) for i in range(n)] minv = float('inf') minv float('inf') float 'inf' maxv = -float('inf') maxv -float('inf') float('inf') float 'inf' for r in R:
    maxv = max(maxv, r-minv)
    minv = min(minv, r) r R maxv = max(maxv, r-minv) maxv max(maxv, r-minv) max maxv r-minv r minv minv = min(minv, r) minv min(minv, r) min minv r print(maxv) print maxv n = int(input()) int(input()) n maxv = -float('inf') -float('inf') maxv maxv = max(maxv, r-minv) max(maxv, r-minv) maxv R = [int(input()) for i in range(n)] [int(input()) for i in range(n)] R minv = min(minv, r) min(minv, r) minv minv = float('inf') float('inf') minv
n = int(input())
R = [int(input()) for i in range(n)]

minv = float('inf')
maxv = -float('inf')
for r in R:
    maxv = max(maxv, r-minv)
    minv = min(minv, r)
print(maxv)