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(input()) for _ in range(int(input()))]
    print(maximum_profit(R)) 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 maximum_profit ret = -float("inf") ret -float("inf") float("inf") float "inf" mi = rate[0] mi rate[0] rate 0 for r in islice(rate, 1, len(rate)):
        ret = max(ret, r - mi)
        mi = min(mi, r)
     r islice(rate, 1, len(rate)) islice rate 1 len(rate) len rate ret = max(ret, r - mi) ret max(ret, r - mi) max ret r - mi r mi mi = min(mi, r) mi min(mi, r) min mi r return ret ret rate rate if __name__ == "__main__":
    R = [int(input()) for _ in range(int(input()))]
    print(maximum_profit(R)) __name__ == "__main__" __name__ "__main__" int(input()) for _ in range(int(input())) for _ in range(int(input())) _ range(int(input())) range int(input()) int input() input for _ in range(int(input())) int(input()) int input() input R = [int(input()) for _ in range(int(input()))] R [int(input()) for _ in range(int(input()))] print(maximum_profit(R)) print maximum_profit(R) maximum_profit R R = [int(input()) for _ in range(int(input()))] [int(input()) for _ in range(int(input()))] R 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 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 maximum_profit
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(input()) for _ in range(int(input()))]
    print(maximum_profit(R))