#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division,
                                print_function, unicode_literals)
import sys

n = int(input())
r = []
for i in range(n):
    r.append(int(input()))

c = sys.maxsize
ret = -sys.maxsize - 1
for j in range(n):
    ret = max([ret, r[j] - c])
    if(r[j] < c):
        c = r[j]

print(ret) from __future__ import (absolute_import, division,
                                print_function, unicode_literals) import sys sys n = int(input()) n int(input()) int input() input r = [] r [] for i in range(n):
    r.append(int(input())) i range(n) range n r.append(int(input())) r.append r append int(input()) int input() input c = sys.maxsize c sys.maxsize sys maxsize ret = -sys.maxsize - 1 ret -sys.maxsize - 1 -sys.maxsize sys.maxsize sys maxsize 1 for j in range(n):
    ret = max([ret, r[j] - c])
    if(r[j] < c):
        c = r[j] j range(n) range n ret = max([ret, r[j] - c]) ret max([ret, r[j] - c]) max [ret, r[j] - c] ret r[j] - c r[j] r j c if(r[j] < c):
        c = r[j] r[j] < c r[j] r j c c = r[j] c r[j] r j print(ret) print ret c = r[j] r[j] c ret = max([ret, r[j] - c]) max([ret, r[j] - c]) ret ret = -sys.maxsize - 1 -sys.maxsize - 1 ret n = int(input()) int(input()) n r = [] [] r c = sys.maxsize sys.maxsize c
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division,
                                print_function, unicode_literals)
import sys

n = int(input())
r = []
for i in range(n):
    r.append(int(input()))

c = sys.maxsize
ret = -sys.maxsize - 1
for j in range(n):
    ret = max([ret, r[j] - c])
    if(r[j] < c):
        c = r[j]

print(ret)