s_max = -float('inf')

s = 0

for i in range(int(eval(input()))):

	r = int(eval(input()))

	if i:

		s = max(s, 0) + r - prev

		s_max = max(s, s_max)

	prev = r

print(s_max)

import sys

s_max = -float('inf')

s = 0

n = int(eval(input()))

r = list(map(int, sys.stdin.read().split()))

for i in range(1, n):

	s = max(s, 0) + r[i] - r[i-1]

	s_max = max(s, s_max)

print(s_max)

s_max = -float("inf")
s = 0
for i in range(int(eval(input()))):
    r = int(eval(input()))
    if i:
        s = max(s, 0) + r - prev
        s_max = max(s, s_max)
    prev = r
print(s_max)

import sys

s_max = -float("inf")
s = 0
n = int(eval(input()))
r = list(map(int, sys.stdin.read().split()))
for i in range(1, n):
    s = max(s, 0) + r[i] - r[i - 1]
    s_max = max(s, s_max)
print(s_max)

+import sys + -for i in range(int(eval(input()))): -    r = int(eval(input())) -    if i: -        s = max(s, 0) + r - prev -        s_max = max(s, s_max) -    prev = r +n = int(eval(input())) +r = list(map(int, sys.stdin.read().split())) +for i in range(1, n): +    s = max(s, 0) + r[i] - r[i - 1] +    s_max = max(s, s_max)