def main():
    n = input()
    d = -999999999

    m = input()
    for i in range(n - 1):
        r = input()
        if (d < r - m):
            d = r - m
        if (m > r):
            m = r
    print(d)

main() def main():
    n = input()
    d = -999999999

    m = input()
    for i in range(n - 1):
        r = input()
        if (d < r - m):
            d = r - m
        if (m > r):
            m = r
    print(d) main n = input() n input() input d = -999999999 d -999999999 m = input() m input() input for i in range(n - 1):
        r = input()
        if (d < r - m):
            d = r - m
        if (m > r):
            m = r
     i range(n - 1) range n - 1 n 1 r = input() r input() input if (d < r - m):
            d = r - m
         d < r - m d r - m r m d = r - m d r - m r m if (m > r):
            m = r
     m > r m r m = r m r print(d) print d main() main def main():
    n = input()
    d = -999999999

    m = input()
    for i in range(n - 1):
        r = input()
        if (d < r - m):
            d = r - m
        if (m > r):
            m = r
    print(d) def main():
    n = input()
    d = -999999999

    m = input()
    for i in range(n - 1):
        r = input()
        if (d < r - m):
            d = r - m
        if (m > r):
            m = r
    print(d) main
def main():
    n = input()
    d = -999999999

    m = input()
    for i in range(n - 1):
        r = input()
        if (d < r - m):
            d = r - m
        if (m > r):
            m = r
    print(d)

main()