n = int(raw_input())

R = [0 for i in range(n)]

ans = 1 - 10**9
for i in range(n):
    R[i] = int(raw_input())
    if i == 0:
        min_R = R[0]
        continue
    if min_R < R[i]:
        if ans < R[i]-min_R:
            ans = R[i] - min_R
    elif min_R > R[i]:
        if ans < R[i]-min_R:
            ans = R[i] - min_R
        min_R = R[i]
    else:
        if ans < 0:
            ans = 0
        
print ans n = int(raw_input()) n int(raw_input()) int raw_input() raw_input 0 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 0 R = [0 for i in range(n)] R [0 for i in range(n)] ans = 1 - 10**9 ans 1 - 10**9 1 10**9 10 9 for i in range(n):
    R[i] = int(raw_input())
    if i == 0:
        min_R = R[0]
        continue
    if min_R < R[i]:
        if ans < R[i]-min_R:
            ans = R[i] - min_R
    elif min_R > R[i]:
        if ans < R[i]-min_R:
            ans = R[i] - min_R
        min_R = R[i]
    else:
        if ans < 0:
            ans = 0
         i range(n) range n R[i] = int(raw_input()) R[i] R i int(raw_input()) int raw_input() raw_input if i == 0:
        min_R = R[0]
        continue
     i == 0 i 0 min_R = R[0] min_R R[0] R 0 continue if min_R < R[i]:
        if ans < R[i]-min_R:
            ans = R[i] - min_R
    elif min_R > R[i]:
        if ans < R[i]-min_R:
            ans = R[i] - min_R
        min_R = R[i]
    else:
        if ans < 0:
            ans = 0
         min_R < R[i] min_R R[i] R i if ans < R[i]-min_R:
            ans = R[i] - min_R
     ans < R[i]-min_R ans R[i]-min_R R[i] R i min_R ans = R[i] - min_R ans R[i] - min_R R[i] R i min_R elif min_R > R[i]:
        if ans < R[i]-min_R:
            ans = R[i] - min_R
        min_R = R[i]
     min_R > R[i] min_R R[i] R i if ans < R[i]-min_R:
            ans = R[i] - min_R
         ans < R[i]-min_R ans R[i]-min_R R[i] R i min_R ans = R[i] - min_R ans R[i] - min_R R[i] R i min_R min_R = R[i] min_R R[i] R i if ans < 0:
            ans = 0
         ans < 0 ans 0 ans = 0 ans 0 print ans = R[i] - min_R R[i] - min_R ans n = int(raw_input()) int(raw_input()) n ans = R[i] - min_R R[i] - min_R ans min_R = R[i] R[i] min_R R = [0 for i in range(n)] [0 for i in range(n)] R ans = 0 0 ans min_R = R[0] R[0] min_R ans = 1 - 10**9 1 - 10**9 ans
n = int(raw_input())

R = [0 for i in range(n)]

ans = 1 - 10**9
for i in range(n):
    R[i] = int(raw_input())
    if i == 0:
        min_R = R[0]
        continue
    if min_R < R[i]:
        if ans < R[i]-min_R:
            ans = R[i] - min_R
    elif min_R > R[i]:
        if ans < R[i]-min_R:
            ans = R[i] - min_R
        min_R = R[i]
    else:
        if ans < 0:
            ans = 0
        
print ans