import sys

n = int(input())

dif_max = -float("inf")
min_v = float("inf")

for i in range(n):
    r = int(sys.stdin.readline())
    dif_max = max(dif_max, r - min_v)
    min_v = min(min_v, r)

print(dif_max) import sys sys n = int(input()) n int(input()) int input() input dif_max = -float("inf") dif_max -float("inf") float("inf") float "inf" min_v = float("inf") min_v float("inf") float "inf" for i in range(n):
    r = int(sys.stdin.readline())
    dif_max = max(dif_max, r - min_v)
    min_v = min(min_v, r) i range(n) range n r = int(sys.stdin.readline()) r int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline dif_max = max(dif_max, r - min_v) dif_max max(dif_max, r - min_v) max dif_max r - min_v r min_v min_v = min(min_v, r) min_v min(min_v, r) min min_v r print(dif_max) print dif_max r = int(sys.stdin.readline()) int(sys.stdin.readline()) r n = int(input()) int(input()) n min_v = min(min_v, r) min(min_v, r) min_v dif_max = -float("inf") -float("inf") dif_max dif_max = max(dif_max, r - min_v) max(dif_max, r - min_v) dif_max min_v = float("inf") float("inf") min_v
import sys

n = int(input())

dif_max = -float("inf")
min_v = float("inf")

for i in range(n):
    r = int(sys.stdin.readline())
    dif_max = max(dif_max, r - min_v)
    min_v = min(min_v, r)

print(dif_max)