N = int(raw_input())
min = int(raw_input())
max = int(raw_input())
dif = max - min
if max < min:
    min = max

for i in range(N - 2):
    R = int(raw_input())
    if R - min > dif:
        dif = R - min
    if R < min:
        min = R

print dif N = int(raw_input()) N int(raw_input()) int raw_input() raw_input min = int(raw_input()) min int(raw_input()) int raw_input() raw_input max = int(raw_input()) max int(raw_input()) int raw_input() raw_input dif = max - min dif max - min max min if max < min:
    min = max max < min max min min = max min max for i in range(N - 2):
    R = int(raw_input())
    if R - min > dif:
        dif = R - min
    if R < min:
        min = R i range(N - 2) range N - 2 N 2 R = int(raw_input()) R int(raw_input()) int raw_input() raw_input if R - min > dif:
        dif = R - min
     R - min > dif R - min R min dif dif = R - min dif R - min R min if R < min:
        min = R R < min R min min = R min R print max = int(raw_input()) int(raw_input()) max R = int(raw_input()) int(raw_input()) R dif = R - min R - min dif min = int(raw_input()) int(raw_input()) min min = R R min dif = max - min max - min dif min = max max min N = int(raw_input()) int(raw_input()) N
N = int(raw_input())
min = int(raw_input())
max = int(raw_input())
dif = max - min
if max < min:
    min = max

for i in range(N - 2):
    R = int(raw_input())
    if R - min > dif:
        dif = R - min
    if R < min:
        min = R

print dif