n = int(input())
mi = int(input())
diff = -9999999999999999
for i in range(n-1):
    now = int(input())
    diff = max(diff, now-mi)
    mi = min(mi, now)
print(diff) n = int(input()) n int(input()) int input() input mi = int(input()) mi int(input()) int input() input diff = -9999999999999999 diff -9999999999999999 for i in range(n-1):
    now = int(input())
    diff = max(diff, now-mi)
    mi = min(mi, now) i range(n-1) range n-1 n 1 now = int(input()) now int(input()) int input() input diff = max(diff, now-mi) diff max(diff, now-mi) max diff now-mi now mi mi = min(mi, now) mi min(mi, now) min mi now print(diff) print diff now = int(input()) int(input()) now mi = min(mi, now) min(mi, now) mi n = int(input()) int(input()) n mi = int(input()) int(input()) mi diff = -9999999999999999 -9999999999999999 diff diff = max(diff, now-mi) max(diff, now-mi) diff
n = int(input())
mi = int(input())
diff = -9999999999999999
for i in range(n-1):
    now = int(input())
    diff = max(diff, now-mi)
    mi = min(mi, now)
print(diff)