N = int(input())

purchase_price = int(input())
profit = -2000000000
for _ in range(N-1):
    price = int(input())
    profit = max(profit, (price-purchase_price))
    purchase_price = min(price, purchase_price)

print(profit) N = int(input()) N int(input()) int input() input purchase_price = int(input()) purchase_price int(input()) int input() input profit = -2000000000 profit -2000000000 for _ in range(N-1):
    price = int(input())
    profit = max(profit, (price-purchase_price))
    purchase_price = min(price, purchase_price) _ range(N-1) range N-1 N 1 price = int(input()) price int(input()) int input() input profit = max(profit, (price-purchase_price)) profit max(profit, (price-purchase_price)) max profit price-purchase_price price purchase_price purchase_price = min(price, purchase_price) purchase_price min(price, purchase_price) min price purchase_price print(profit) print profit price = int(input()) int(input()) price profit = max(profit, (price-purchase_price)) max(profit, (price-purchase_price)) profit purchase_price = min(price, purchase_price) min(price, purchase_price) purchase_price profit = -2000000000 -2000000000 profit purchase_price = int(input()) int(input()) purchase_price N = int(input()) int(input()) N
N = int(input())

purchase_price = int(input())
profit = -2000000000
for _ in range(N-1):
    price = int(input())
    profit = max(profit, (price-purchase_price))
    purchase_price = min(price, purchase_price)

print(profit)
