import sys
input()
mx = -float('inf')
res = mx
mn = int(input())
for i in map(int,sys.stdin.readlines()):
        if mx < i - mn:
            mx = i - mn
        if 0 > i - mn:
            mn = i
        res = max(mx,res)
print(res) import sys sys input() input mx = -float('inf') mx -float('inf') float('inf') float 'inf' res = mx res mx mn = int(input()) mn int(input()) int input() input for i in map(int,sys.stdin.readlines()):
        if mx < i - mn:
            mx = i - mn
        if 0 > i - mn:
            mn = i
        res = max(mx,res) i map(int,sys.stdin.readlines()) map int sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines if mx < i - mn:
            mx = i - mn
         mx < i - mn mx i - mn i mn mx = i - mn mx i - mn i mn if 0 > i - mn:
            mn = i
         0 > i - mn 0 i - mn i mn mn = i mn i res = max(mx,res) res max(mx,res) max mx res print(res) print res mn = int(input()) int(input()) mn res = max(mx,res) max(mx,res) res mx = i - mn i - mn mx mn = i i mn res = mx mx res mx = -float('inf') -float('inf') mx
import sys
input()
mx = -float('inf')
res = mx
mn = int(input())
for i in map(int,sys.stdin.readlines()):
        if mx < i - mn:
            mx = i - mn
        if 0 > i - mn:
            mn = i
        res = max(mx,res)
print(res)