n = int(input())

min_price = int(input())
max_diff = -1e9

for _ in range(n - 1):
    p = int(input())
    max_diff = max(p - min_price, max_diff)
    min_price = min(p, min_price)

print(max_diff) n = int(input()) n int(input()) int input() input min_price = int(input()) min_price int(input()) int input() input max_diff = -1e9 max_diff -1e9 for _ in range(n - 1):
    p = int(input())
    max_diff = max(p - min_price, max_diff)
    min_price = min(p, min_price) _ range(n - 1) range n - 1 n 1 p = int(input()) p int(input()) int input() input max_diff = max(p - min_price, max_diff) max_diff max(p - min_price, max_diff) max p - min_price p min_price max_diff min_price = min(p, min_price) min_price min(p, min_price) min p min_price print(max_diff) print max_diff max_diff = max(p - min_price, max_diff) max(p - min_price, max_diff) max_diff max_diff = -1e9 -1e9 max_diff p = int(input()) int(input()) p min_price = int(input()) int(input()) min_price n = int(input()) int(input()) n min_price = min(p, min_price) min(p, min_price) min_price
n = int(input())

min_price = int(input())
max_diff = -1e9

for _ in range(n - 1):
    p = int(input())
    max_diff = max(p - min_price, max_diff)
    min_price = min(p, min_price)

print(max_diff)