num=int(input())
r_1=int(input())
r_2=int(input())

max_profit=r_2-r_1
if r_1<r_2:
    min_value=r_1
else:
    min_value=r_2

for i in range(2,num):
    x=int(input())
    t=x-min_value
    if max_profit<t:
        max_profit=t
    if x<min_value:
        min_value=x
        
print(max_profit) num=int(input()) num int(input()) int input() input r_1=int(input()) r_1 int(input()) int input() input r_2=int(input()) r_2 int(input()) int input() input max_profit=r_2-r_1 max_profit r_2-r_1 r_2 r_1 if r_1<r_2:
    min_value=r_1
else:
    min_value=r_2 r_1<r_2 r_1 r_2 min_value=r_1 min_value r_1 min_value=r_2 min_value r_2 for i in range(2,num):
    x=int(input())
    t=x-min_value
    if max_profit<t:
        max_profit=t
    if x<min_value:
        min_value=x
         i range(2,num) range 2 num x=int(input()) x int(input()) int input() input t=x-min_value t x-min_value x min_value if max_profit<t:
        max_profit=t
     max_profit<t max_profit t max_profit=t max_profit t if x<min_value:
        min_value=x
         x<min_value x min_value min_value=x min_value x print(max_profit) print max_profit r_1=int(input()) int(input()) r_1 r_2=int(input()) int(input()) r_2 max_profit=r_2-r_1 r_2-r_1 max_profit min_value=r_1 r_1 min_value t=x-min_value x-min_value t max_profit=t t max_profit min_value=r_2 r_2 min_value num=int(input()) int(input()) num min_value=x x min_value x=int(input()) int(input()) x
num=int(input())
r_1=int(input())
r_2=int(input())

max_profit=r_2-r_1
if r_1<r_2:
    min_value=r_1
else:
    min_value=r_2

for i in range(2,num):
    x=int(input())
    t=x-min_value
    if max_profit<t:
        max_profit=t
    if x<min_value:
        min_value=x
        
print(max_profit)