import sys

line_num = int(sys.stdin.readline().rstrip())
maxv = -2000000000
minv = int(sys.stdin.readline().rstrip())

for i in range(1, line_num):
    rt = int(sys.stdin.readline())
    if rt - minv > maxv:
        maxv = rt - minv
    if rt < minv:
        minv = rt

print(maxv) import sys sys line_num = int(sys.stdin.readline().rstrip()) line_num int(sys.stdin.readline().rstrip()) int sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip maxv = -2000000000 maxv -2000000000 minv = int(sys.stdin.readline().rstrip()) minv int(sys.stdin.readline().rstrip()) int sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip for i in range(1, line_num):
    rt = int(sys.stdin.readline())
    if rt - minv > maxv:
        maxv = rt - minv
    if rt < minv:
        minv = rt i range(1, line_num) range 1 line_num rt = int(sys.stdin.readline()) rt int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline if rt - minv > maxv:
        maxv = rt - minv
     rt - minv > maxv rt - minv rt minv maxv maxv = rt - minv maxv rt - minv rt minv if rt < minv:
        minv = rt rt < minv rt minv minv = rt minv rt print(maxv) print maxv maxv = -2000000000 -2000000000 maxv rt = int(sys.stdin.readline()) int(sys.stdin.readline()) rt line_num = int(sys.stdin.readline().rstrip()) int(sys.stdin.readline().rstrip()) line_num minv = rt rt minv maxv = rt - minv rt - minv maxv minv = int(sys.stdin.readline().rstrip()) int(sys.stdin.readline().rstrip()) minv
import sys

line_num = int(sys.stdin.readline().rstrip())
maxv = -2000000000
minv = int(sys.stdin.readline().rstrip())

for i in range(1, line_num):
    rt = int(sys.stdin.readline())
    if rt - minv > maxv:
        maxv = rt - minv
    if rt < minv:
        minv = rt

print(maxv)