# -*- Coding: utf-8 -*-

nums = int(input())
a = [int(input()) for i in range(nums)]

minv = a[0]
maxv = -2000000000

for i in range(1, nums):
    maxv = max(maxv, a[i] - minv)
    minv = min(minv, a[i])

print(maxv)
 nums = int(input()) nums int(input()) int input() input int(input()) for i in range(nums) for i in range(nums) i range(nums) range nums for i in range(nums) int(input()) int input() input a = [int(input()) for i in range(nums)] a [int(input()) for i in range(nums)] minv = a[0] minv a[0] a 0 maxv = -2000000000 maxv -2000000000 for i in range(1, nums):
    maxv = max(maxv, a[i] - minv)
    minv = min(minv, a[i]) i range(1, nums) range 1 nums maxv = max(maxv, a[i] - minv) maxv max(maxv, a[i] - minv) max maxv a[i] - minv a[i] a i minv minv = min(minv, a[i]) minv min(minv, a[i]) min minv a[i] a i print(maxv) print maxv minv = a[0] a[0] minv nums = int(input()) int(input()) nums maxv = -2000000000 -2000000000 maxv maxv = max(maxv, a[i] - minv) max(maxv, a[i] - minv) maxv minv = min(minv, a[i]) min(minv, a[i]) minv a = [int(input()) for i in range(nums)] [int(input()) for i in range(nums)] a
# -*- Coding: utf-8 -*-

nums = int(input())
a = [int(input()) for i in range(nums)]

minv = a[0]
maxv = -2000000000

for i in range(1, nums):
    maxv = max(maxv, a[i] - minv)
    minv = min(minv, a[i])

print(maxv)

