import sys


fin = sys.stdin.readline
n = int(fin())
price_list = [int(fin()) for _ in range(n)]
min_price_so_far = float('inf')
max_profit = float('-inf')
for price in price_list:
    profit = price - min_price_so_far
    max_profit = max(max_profit, profit)
    min_price_so_far = min(min_price_so_far, price)
print(max_profit)
 import sys sys fin = sys.stdin.readline fin sys.stdin.readline sys.stdin sys stdin readline n = int(fin()) n int(fin()) int fin() fin int(fin()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(fin()) int fin() fin price_list = [int(fin()) for _ in range(n)] price_list [int(fin()) for _ in range(n)] min_price_so_far = float('inf') min_price_so_far float('inf') float 'inf' max_profit = float('-inf') max_profit float('-inf') float '-inf' for price in price_list:
    profit = price - min_price_so_far
    max_profit = max(max_profit, profit)
    min_price_so_far = min(min_price_so_far, price) price price_list profit = price - min_price_so_far profit price - min_price_so_far price min_price_so_far max_profit = max(max_profit, profit) max_profit max(max_profit, profit) max max_profit profit min_price_so_far = min(min_price_so_far, price) min_price_so_far min(min_price_so_far, price) min min_price_so_far price print(max_profit) print max_profit fin = sys.stdin.readline sys.stdin.readline fin price_list = [int(fin()) for _ in range(n)] [int(fin()) for _ in range(n)] price_list min_price_so_far = min(min_price_so_far, price) min(min_price_so_far, price) min_price_so_far max_profit = max(max_profit, profit) max(max_profit, profit) max_profit min_price_so_far = float('inf') float('inf') min_price_so_far n = int(fin()) int(fin()) n profit = price - min_price_so_far price - min_price_so_far profit max_profit = float('-inf') float('-inf') max_profit
import sys


fin = sys.stdin.readline
n = int(fin())
price_list = [int(fin()) for _ in range(n)]
min_price_so_far = float('inf')
max_profit = float('-inf')
for price in price_list:
    profit = price - min_price_so_far
    max_profit = max(max_profit, profit)
    min_price_so_far = min(min_price_so_far, price)
print(max_profit)

