def main():
    N = int(input())
    price = [int(input()) for i in range(N)]
    minv = float("inf")
    maxv = -float("inf")
    for p in price:
        maxv = max(maxv, p-minv)
        minv = min(minv, p)
    print(maxv)



if __name__ == "__main__":
    import os
    import sys
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main() def main():
    N = int(input())
    price = [int(input()) for i in range(N)]
    minv = float("inf")
    maxv = -float("inf")
    for p in price:
        maxv = max(maxv, p-minv)
        minv = min(minv, p)
    print(maxv) main N = int(input()) N int(input()) int input() input int(input()) for i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input price = [int(input()) for i in range(N)] price [int(input()) for i in range(N)] minv = float("inf") minv float("inf") float "inf" maxv = -float("inf") maxv -float("inf") float("inf") float "inf" for p in price:
        maxv = max(maxv, p-minv)
        minv = min(minv, p)
     p price maxv = max(maxv, p-minv) maxv max(maxv, p-minv) max maxv p-minv p minv minv = min(minv, p) minv min(minv, p) min minv p print(maxv) print maxv if __name__ == "__main__":
    import os
    import sys
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main() __name__ == "__main__" __name__ "__main__" import os os import sys sys if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main() len(sys.argv) > 1 len(sys.argv) len sys.argv sys argv 1 if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
     sys.argv[1] == "-d" sys.argv[1] sys.argv sys argv 1 "-d" fd = os.open("input.txt", os.O_RDONLY) fd os.open("input.txt", os.O_RDONLY) os.open os open "input.txt" os.O_RDONLY os O_RDONLY os.dup2(fd, sys.stdin.fileno()) os.dup2 os dup2 fd sys.stdin.fileno() sys.stdin.fileno sys.stdin sys stdin fileno main() main main() main fd = os.open("input.txt", os.O_RDONLY) os.open("input.txt", os.O_RDONLY) fd def main():
    N = int(input())
    price = [int(input()) for i in range(N)]
    minv = float("inf")
    maxv = -float("inf")
    for p in price:
        maxv = max(maxv, p-minv)
        minv = min(minv, p)
    print(maxv) def main():
    N = int(input())
    price = [int(input()) for i in range(N)]
    minv = float("inf")
    maxv = -float("inf")
    for p in price:
        maxv = max(maxv, p-minv)
        minv = min(minv, p)
    print(maxv) main
def main():
    N = int(input())
    price = [int(input()) for i in range(N)]
    minv = float("inf")
    maxv = -float("inf")
    for p in price:
        maxv = max(maxv, p-minv)
        minv = min(minv, p)
    print(maxv)



if __name__ == "__main__":
    import os
    import sys
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()