n = int(input())
inf = 10 ** 10
buy = inf
ans = -inf
for i in range(n):
    price = int(input())
    ans = max(ans, price - buy)
    buy = min(buy, price)
print(ans)
 n = int(input()) n int(input()) int input() input inf = 10 ** 10 inf 10 ** 10 10 10 buy = inf buy inf ans = -inf ans -inf inf for i in range(n):
    price = int(input())
    ans = max(ans, price - buy)
    buy = min(buy, price) i range(n) range n price = int(input()) price int(input()) int input() input ans = max(ans, price - buy) ans max(ans, price - buy) max ans price - buy price buy buy = min(buy, price) buy min(buy, price) min buy price print(ans) print ans n = int(input()) int(input()) n buy = min(buy, price) min(buy, price) buy price = int(input()) int(input()) price inf = 10 ** 10 10 ** 10 inf ans = -inf -inf ans buy = inf inf buy ans = max(ans, price - buy) max(ans, price - buy) ans
n = int(input())
inf = 10 ** 10
buy = inf
ans = -inf
for i in range(n):
    price = int(input())
    ans = max(ans, price - buy)
    buy = min(buy, price)
print(ans)

