n = int(input())

maximum_profit = -10**9
r0 = int(input())
r_min = r0
for i in range(1, n):
    r1 = int(input())
    if r0 < r_min:
        r_min = r0
    profit = r1 - r_min
    if profit > maximum_profit:
        maximum_profit = profit
    r0 = r1
print(maximum_profit) n = int(input()) n int(input()) int input() input maximum_profit = -10**9 maximum_profit -10**9 -10 9 r0 = int(input()) r0 int(input()) int input() input r_min = r0 r_min r0 for i in range(1, n):
    r1 = int(input())
    if r0 < r_min:
        r_min = r0
    profit = r1 - r_min
    if profit > maximum_profit:
        maximum_profit = profit
    r0 = r1 i range(1, n) range 1 n r1 = int(input()) r1 int(input()) int input() input if r0 < r_min:
        r_min = r0
     r0 < r_min r0 r_min r_min = r0 r_min r0 profit = r1 - r_min profit r1 - r_min r1 r_min if profit > maximum_profit:
        maximum_profit = profit
     profit > maximum_profit profit maximum_profit maximum_profit = profit maximum_profit profit r0 = r1 r0 r1 print(maximum_profit) print maximum_profit r_min = r0 r0 r_min maximum_profit = -10**9 -10**9 maximum_profit r1 = int(input()) int(input()) r1 profit = r1 - r_min r1 - r_min profit r0 = r1 r1 r0 maximum_profit = profit profit maximum_profit r_min = r0 r0 r_min r0 = int(input()) int(input()) r0 n = int(input()) int(input()) n
n = int(input())

maximum_profit = -10**9
r0 = int(input())
r_min = r0
for i in range(1, n):
    r1 = int(input())
    if r0 < r_min:
        r_min = r0
    profit = r1 - r_min
    if profit > maximum_profit:
        maximum_profit = profit
    r0 = r1
print(maximum_profit)