# ??\?????????
N = int(input())
r = [int(input()) for i in range(N)]

# ?????§????¨????
max_profit = (-1) * (10 ** 9)
min_value = r[0]
for j in range(1, len(r)):
    max_profit = max(max_profit, r[j] - min_value)
    min_value = min(min_value, r[j])
print(max_profit) N = int(input()) N int(input()) int input() input int(input()) for i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input r = [int(input()) for i in range(N)] r [int(input()) for i in range(N)] max_profit = (-1) * (10 ** 9) max_profit (-1) * (10 ** 9) -1 10 ** 9 10 9 min_value = r[0] min_value r[0] r 0 for j in range(1, len(r)):
    max_profit = max(max_profit, r[j] - min_value)
    min_value = min(min_value, r[j]) j range(1, len(r)) range 1 len(r) len r max_profit = max(max_profit, r[j] - min_value) max_profit max(max_profit, r[j] - min_value) max max_profit r[j] - min_value r[j] r j min_value min_value = min(min_value, r[j]) min_value min(min_value, r[j]) min min_value r[j] r j print(max_profit) print max_profit r = [int(input()) for i in range(N)] [int(input()) for i in range(N)] r max_profit = (-1) * (10 ** 9) (-1) * (10 ** 9) max_profit min_value = min(min_value, r[j]) min(min_value, r[j]) min_value min_value = r[0] r[0] min_value N = int(input()) int(input()) N max_profit = max(max_profit, r[j] - min_value) max(max_profit, r[j] - min_value) max_profit
# ??\?????????
N = int(input())
r = [int(input()) for i in range(N)]

# ?????§????¨????
max_profit = (-1) * (10 ** 9)
min_value = r[0]
for j in range(1, len(r)):
    max_profit = max(max_profit, r[j] - min_value)
    min_value = min(min_value, r[j])
print(max_profit)