

n = int(eval(input()))



dif_max = -float("inf")

min_v = float("inf")



for i in range(n):

    r = int(eval(input()))

    dif_max = max(dif_max, r - min_v)

    min_v = min(min_v, r)



print(dif_max)
import sys



n = int(eval(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)
n = int(eval(input()))
dif_max = -float("inf")
min_v = float("inf")
for i in range(n):
    r = int(eval(input()))
    dif_max = max(dif_max, r - min_v)
    min_v = min(min_v, r)
print(dif_max)

import sys

n = int(eval(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 + -    r = int(eval(input())) +    r = int(sys.stdin.readline())