mini = pre = float("inf")

def f(n):

    global mini, pre

    mini = min(mini, pre)

    pre = n

    return n - mini

print(max(f(eval(input())) for _ in range(eval(input()))))
from itertools import islice





def maximum_profit(rate):

    ret = -float("inf")

    mi = rate[0]

    for r in islice(rate, 1, len(rate)):

        ret = max(ret, r - mi)

        mi = min(mi, r)

    return ret



if __name__ == "__main__":

    R = [int(eval(input())) for _ in range(int(eval(input())))]

    print((maximum_profit(R)))
mini = pre = float("inf")


def f(n):
    global mini, pre
    mini = min(mini, pre)
    pre = n
    return n - mini


print(max(f(eval(input())) for _ in range(eval(input()))))

from itertools import islice


def maximum_profit(rate):
    ret = -float("inf")
    mi = rate[0]
    for r in islice(rate, 1, len(rate)):
        ret = max(ret, r - mi)
        mi = min(mi, r)
    return ret


if __name__ == "__main__":
    R = [int(eval(input())) for _ in range(int(eval(input())))]
    print((maximum_profit(R)))

-mini = pre = float("inf") +from itertools import islice -def f(n): -    global mini, pre -    mini = min(mini, pre) -    pre = n -    return n - mini +def maximum_profit(rate): +    ret = -float("inf") +    mi = rate[0] +    for r in islice(rate, 1, len(rate)): +        ret = max(ret, r - mi) +        mi = min(mi, r) +    return ret -print(max(f(eval(input())) for _ in range(eval(input())))) +if __name__ == "__main__": +    R = [int(eval(input())) for _ in range(int(eval(input())))] +    print((maximum_profit(R)))