N = int(input())
R = [int(input()) for _ in range(N)]

p_buy = R[0]
p_sale = R[1]
buy = R[1]
sale = None
for i in range(2, N):
    if p_sale < R[i]:
        p_sale = R[i]
    if buy > R[i]:
        if sale is None:
            sale = R[i]
        if p_sale - p_buy < sale - buy:
            p_sale, p_buy = sale, buy 
        sale, buy = None, R[i]
    else:
        if sale is None or sale < R[i]:
            sale = R[i]

p_gain = p_sale - p_buy
print(p_gain if sale is None else max(p_gain, sale - buy)) N = int(input()) N int(input()) int input() input int(input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input R = [int(input()) for _ in range(N)] R [int(input()) for _ in range(N)] p_buy = R[0] p_buy R[0] R 0 p_sale = R[1] p_sale R[1] R 1 buy = R[1] buy R[1] R 1 sale = None sale None for i in range(2, N):
    if p_sale < R[i]:
        p_sale = R[i]
    if buy > R[i]:
        if sale is None:
            sale = R[i]
        if p_sale - p_buy < sale - buy:
            p_sale, p_buy = sale, buy 
        sale, buy = None, R[i]
    else:
        if sale is None or sale < R[i]:
            sale = R[i] i range(2, N) range 2 N if p_sale < R[i]:
        p_sale = R[i]
     p_sale < R[i] p_sale R[i] R i p_sale = R[i] p_sale R[i] R i if buy > R[i]:
        if sale is None:
            sale = R[i]
        if p_sale - p_buy < sale - buy:
            p_sale, p_buy = sale, buy 
        sale, buy = None, R[i]
    else:
        if sale is None or sale < R[i]:
            sale = R[i] buy > R[i] buy R[i] R i if sale is None:
            sale = R[i]
         sale is None sale None sale = R[i] sale R[i] R i if p_sale - p_buy < sale - buy:
            p_sale, p_buy = sale, buy 
         p_sale - p_buy < sale - buy p_sale - p_buy p_sale p_buy sale - buy sale buy p_sale, p_buy = sale, buy p_sale sale p_buy buy sale, buy = None, R[i] sale None buy R[i] R i if sale is None or sale < R[i]:
            sale = R[i] sale is None or sale < R[i] sale is None sale None sale < R[i] sale R[i] R i sale = R[i] sale R[i] R i p_gain = p_sale - p_buy p_gain p_sale - p_buy p_sale p_buy print(p_gain if sale is None else max(p_gain, sale - buy)) print p_gain if sale is None else max(p_gain, sale - buy) sale is None sale None p_gain max(p_gain, sale - buy) max p_gain sale - buy sale buy sale = R[i] R[i] sale p_gain = p_sale - p_buy p_sale - p_buy p_gain sale, buy = None, R[i] None sale p_sale = R[1] R[1] p_sale buy = None, R[i] R[i] buy sale = R[i] R[i] sale p_buy = R[0] R[0] p_buy sale = None None sale R = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] R buy = R[1] R[1] buy p_sale = R[i] R[i] p_sale p_buy = sale, buy buy p_buy N = int(input()) int(input()) N p_sale, p_buy = sale, buy sale p_sale
N = int(input())
R = [int(input()) for _ in range(N)]

p_buy = R[0]
p_sale = R[1]
buy = R[1]
sale = None
for i in range(2, N):
    if p_sale < R[i]:
        p_sale = R[i]
    if buy > R[i]:
        if sale is None:
            sale = R[i]
        if p_sale - p_buy < sale - buy:
            p_sale, p_buy = sale, buy 
        sale, buy = None, R[i]
    else:
        if sale is None or sale < R[i]:
            sale = R[i]

p_gain = p_sale - p_buy
print(p_gain if sale is None else max(p_gain, sale - buy))