import sys

num = int(sys.stdin.readline().strip())

r0 = int(sys.stdin.readline().strip())
r1 = int(sys.stdin.readline().strip())

max_dis = r1 - r0
min_num = min(r0, r1)

for i in range(0, num-2):
    r = int(sys.stdin.readline().strip())
    max_dis = max(max_dis, r - min_num)
    min_num = min(min_num, r)

print max_dis import sys sys num = int(sys.stdin.readline().strip()) num int(sys.stdin.readline().strip()) int sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip r0 = int(sys.stdin.readline().strip()) r0 int(sys.stdin.readline().strip()) int sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip r1 = int(sys.stdin.readline().strip()) r1 int(sys.stdin.readline().strip()) int sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip max_dis = r1 - r0 max_dis r1 - r0 r1 r0 min_num = min(r0, r1) min_num min(r0, r1) min r0 r1 for i in range(0, num-2):
    r = int(sys.stdin.readline().strip())
    max_dis = max(max_dis, r - min_num)
    min_num = min(min_num, r) i range(0, num-2) range 0 num-2 num 2 r = int(sys.stdin.readline().strip()) r int(sys.stdin.readline().strip()) int sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip max_dis = max(max_dis, r - min_num) max_dis max(max_dis, r - min_num) max max_dis r - min_num r min_num min_num = min(min_num, r) min_num min(min_num, r) min min_num r print min_num = min(r0, r1) min(r0, r1) min_num r1 = int(sys.stdin.readline().strip()) int(sys.stdin.readline().strip()) r1 max_dis = r1 - r0 r1 - r0 max_dis num = int(sys.stdin.readline().strip()) int(sys.stdin.readline().strip()) num r0 = int(sys.stdin.readline().strip()) int(sys.stdin.readline().strip()) r0 min_num = min(min_num, r) min(min_num, r) min_num r = int(sys.stdin.readline().strip()) int(sys.stdin.readline().strip()) r max_dis = max(max_dis, r - min_num) max(max_dis, r - min_num) max_dis
import sys

num = int(sys.stdin.readline().strip())

r0 = int(sys.stdin.readline().strip())
r1 = int(sys.stdin.readline().strip())

max_dis = r1 - r0
min_num = min(r0, r1)

for i in range(0, num-2):
    r = int(sys.stdin.readline().strip())
    max_dis = max(max_dis, r - min_num)
    min_num = min(min_num, r)

print max_dis