# coding: utf-8

n = int(input())

max_val = -10 ** 10
min_val = int(input())

for i in range(n - 1):
    t = int(input())
    max_val = max(max_val, t - min_val)
    min_val = min(min_val, t)

print(max_val) n = int(input()) n int(input()) int input() input max_val = -10 ** 10 max_val -10 ** 10 -10 10 min_val = int(input()) min_val int(input()) int input() input for i in range(n - 1):
    t = int(input())
    max_val = max(max_val, t - min_val)
    min_val = min(min_val, t) i range(n - 1) range n - 1 n 1 t = int(input()) t int(input()) int input() input max_val = max(max_val, t - min_val) max_val max(max_val, t - min_val) max max_val t - min_val t min_val min_val = min(min_val, t) min_val min(min_val, t) min min_val t print(max_val) print max_val t = int(input()) int(input()) t n = int(input()) int(input()) n min_val = min(min_val, t) min(min_val, t) min_val max_val = max(max_val, t - min_val) max(max_val, t - min_val) max_val max_val = -10 ** 10 -10 ** 10 max_val min_val = int(input()) int(input()) min_val
# coding: utf-8

n = int(input())

max_val = -10 ** 10
min_val = int(input())

for i in range(n - 1):
    t = int(input())
    max_val = max(max_val, t - min_val)
    min_val = min(min_val, t)

print(max_val)