#! /usr/local/bin/python3
# coding: utf-8

n = int(input())

min_r = int(input())
max_margin = -1000000001

for i in range(n - 1):
    r = int(input())
    max_margin = max(r - min_r, max_margin)
    min_r = min(r, min_r)

print(max_margin) n = int(input()) n int(input()) int input() input min_r = int(input()) min_r int(input()) int input() input max_margin = -1000000001 max_margin -1000000001 for i in range(n - 1):
    r = int(input())
    max_margin = max(r - min_r, max_margin)
    min_r = min(r, min_r) i range(n - 1) range n - 1 n 1 r = int(input()) r int(input()) int input() input max_margin = max(r - min_r, max_margin) max_margin max(r - min_r, max_margin) max r - min_r r min_r max_margin min_r = min(r, min_r) min_r min(r, min_r) min r min_r print(max_margin) print max_margin r = int(input()) int(input()) r max_margin = max(r - min_r, max_margin) max(r - min_r, max_margin) max_margin min_r = min(r, min_r) min(r, min_r) min_r n = int(input()) int(input()) n min_r = int(input()) int(input()) min_r max_margin = -1000000001 -1000000001 max_margin
#! /usr/local/bin/python3
# coding: utf-8

n = int(input())

min_r = int(input())
max_margin = -1000000001

for i in range(n - 1):
    r = int(input())
    max_margin = max(r - min_r, max_margin)
    min_r = min(r, min_r)

print(max_margin)
