CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
stack = []
for _ in range(n):
    stack.append(int(eval(input())))
length = len(stack)

candidate = [-float('inf')]
for i in range(1, length // 2 + 1):
    for r1, r2 in zip(stack[::1], stack[i::1]):
        if r2 - r1 > candidate[0]:
            candidate.append(r2 - r1)
    if i - length != i:
        for r1, r2 in zip(stack[::1], stack[length - i::1]):
            if r2 - r1 > candidate[0]:
                candidate.append(r2 - r1)
    candidate = [max(candidate)]

print((candidate[0]))

# Optimized solution
n = int(eval(input()))
stack = []
for _ in range(n):
    stack.append(int(eval(input())))

maxv = -10**9
minv = stack[0]
for i in range(1, len(stack)):
    maxv = max(maxv, stack[i] - minv)
    minv = min(minv, stack[i])

print(maxv)
# Original solution
def main():
    n = int(eval(input()))
    r = []
    ans = 0
    for i in range(n):
        r.append(int(eval(input())))

    ans = min(r) - max(r)
    for i in reversed(list(range(1, n))):
        tmpr = r[:i]
        tmp = r[i] - min(tmpr)
        if tmp > ans:
            ans = tmp
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    n = int(eval(input()))
    ans = 0
    minr = int(eval(input()))
    ans = -1 * 10**9
    for i in range(n-1):
        r = int(eval(input()))
        ans = max(ans, r-minr)
        minr = min(minr, r)

    print(ans)


if __name__ == '__main__':
    main()
# Original solution
n = int(eval(input()))
R = []
for i in range(n):
    R.append(int(eval(input())))

# R???i???????????§???????°???????i?????????????´???¨???????????????list
mins = [R[0]]
for i in range(1, n):
    mins.append(min(R[i], mins[i-1]))

# ???????????????j????????????????????\??????????°??????¨??????????±?????????????????????§???????±????????????????
mx = - 10 ** 12
for j in range(1, n):
    mx = max(mx, R[j] - mins[j-1])

print(mx)

# Optimized solution
n = int(eval(input()))

# R[0]
minv = int(eval(input()))
maxv = - 10 ** 10

# R[1..N-1]
for j in range(1, n):
    r = int(eval(input()))
    maxv = max(maxv, r - minv)
    minv = min(minv, r)

print(maxv)
# Original solution
n = int(eval(input()))
minv = int(eval(input()))
maxv = -1000000000

for i in range(1,n):
  r = int(eval(input()))
  maxv = max(maxv,r-minv)
  minv = min(r,minv)

print(maxv)

# Optimized solution
n = int(eval(input()))
minv = int(eval(input()))
maxv = -1000000000

for i in range(1,n):
  r = int(eval(input()))
  m = r-minv
  if maxv < m < 0:
    maxv = m
    minv = r
  elif maxv < m:
    maxv = m
  elif m < 0:
    minv = r

print(maxv)
# Original solution
n = int(eval(input()))
minv = int(eval(input()))
maxv = -1000000000

for i in range(1,n):
  r = int(eval(input()))
  m = r-minv
  if maxv < m < 0:
    maxv = m
    minv = r
  elif maxv < m:
    maxv = m
  elif m < 0:
    minv = r

print(maxv)

# Optimized solution
import sys

n = int(eval(input()))
minv = int(eval(input()))
maxv = -1000000000

for r in map(int,sys.stdin.readlines()):
  m = r-minv
  if maxv < m < 0:
    maxv = m
    minv = r
  elif maxv < m:
    maxv = m
  elif m < 0:
    minv = r

print(maxv)
# Original solution
n = int(eval(input()))
nums = [int(eval(input())) for i in range(n)]
ans = -10000000000

for i in range(1, n):
    temp_max = nums[i:n+1]
    temp_min = nums[0:i]
    ans = max(ans, max(temp_max) - min(temp_min))
print(ans)	

# Optimized solution
n = int(eval(input()))
nums = [int(eval(input())) for i in range(n)]
temp = nums[1] - nums[0]
p = nums[0]

for i in nums[1:]:
    if i - p > temp:
        temp = i- p
    if i < p:
        p = i
print(temp)
# Original solution
input_profit = []
for x in range(eval(input())):
    input_profit.append(eval(input()))
max_profit=input_profit[1]-input_profit[0]
for i in range(len(input_profit)-1):
    min_profit = input_profit[i]
    candidate = max(input_profit[i+1:])-min_profit
    if candidate>max_profit:
        max_profit=candidate
print(max_profit)

# Optimized solution
input_n = eval(input())
price1  = eval(input())
price2  = eval(input())
min_price = min(price1,price2)
max_profit = price2-price1
for i in range(input_n-2):
    input_profit = eval(input())
    tmp = input_profit-min_price
    if max_profit<tmp:
        max_profit = tmp
    if min_price>input_profit:
        min_price = input_profit
print(max_profit)
# Original solution
from sys import stdin
n = int(eval(input()))
r=[int(eval(input())) for i in range(n)]
rv = r[::-1][:-1]
m = None
for j,r_j in enumerate(rv):
    r_i = min(r[:-(j+1)])
    t = r_j - r_i
    if m == None or t > m:
        m = t
print(m)

# Optimized solution
from sys import stdin
n = int(eval(input()))
r=[int(eval(input())) for i in range(n)]
rv = r[::-1][:-1]
m = None
p_r_j = None
for j,r_j in enumerate(rv):
    if p_r_j == None or p_r_j < r_j:
        p_r_j = r_j
    if p_r_j > r_j:
        continue
    r_i = min(r[:-(j+1)])
    t = r_j - r_i
    if m == None or t > m:
        m = t
print(m)
# Original solution
from sys import stdin
n = int(eval(input()))
r=[int(eval(input())) for i in range(n)]
rv = r[::-1][:-1]
m = None
p_r_j = None
for j,r_j in enumerate(rv):
    if p_r_j == None or p_r_j < r_j:
        p_r_j = r_j
    if p_r_j > r_j:
        continue
    r_i = min(r[:-(j+1)])
    t = r_j - r_i
    if m == None or t > m:
        m = t
print(m)

# Optimized solution
n = int(eval(input()))
minv = int(eval(input()))
maxv = -2*10**9
for i in range(n-1):
    r = int(eval(input()))
    maxv = max(maxv,r-minv)
    minv = min(minv,r)
print(maxv)
# Original solution
N = int(eval(input()))
a = []
for i in range(N):
    a.append(int(eval(input())))
mx = -10**12
for j in range(1, N):
    for i in range(j):
        mx = max(mx, a[j] - a[i])
print(mx)

# Optimized solution
N = int(eval(input()))
a = []
for i in range(N):
    a.append(int(eval(input())))

mins = [a[0]]
for i in range(1, N):
    mins.append(min(a[i], mins[i-1]))
    
mx = -10**12
for j in range(1, N):
    mx = max(mx, a[j] - mins[j-1])
print(mx)
# Original solution
n = int(eval(input()))
R = [0]*n

for i in range(n):
    R[i] = int(eval(input()))

maximum_profit = -10**9
for i in range(1, n):
    profit = max(R[i:n]) - min(R[0:i])
    maximum_profit = profit if profit > maximum_profit else maximum_profit

print(maximum_profit)

# Optimized solution
debug = False

if debug:import time
if debug:start = time.time()

n = int(eval(input()))
R = [0]*n
R_min = 10**9

for i in range(n):
    R[i] = int(eval(input()))

maximum_profit = -10**9
for i in range(1, n):
    R_min = R[i-1] if R[i-1] < R_min else R_min
    profit = R[i] - R_min
    maximum_profit = profit if profit > maximum_profit else maximum_profit
print(maximum_profit)

if debug:print((time.time() - start))
# Original solution
debug = False

if debug:import time
if debug:start = time.time()

n = int(eval(input()))
R = [0]*n
R_min = 10**9

for i in range(n):
    R[i] = int(eval(input()))

maximum_profit = -10**9
for i in range(1, n):
    R_min = R[i-1] if R[i-1] < R_min else R_min
    profit = R[i] - R_min
    maximum_profit = profit if profit > maximum_profit else maximum_profit
print(maximum_profit)

if debug:print((time.time() - start))

# Optimized solution
debug = False

if debug:import time
if debug:start = time.time()

n = int(eval(input()))
R = [0]*n
R_min = 10**9

R = [int(eval(input())) for i in range(n)]

maximum_profit = -10**9
for i in range(1, n):
    R_min = R[i-1] if R[i-1] < R_min else R_min
    profit = R[i] - R_min
    maximum_profit = profit if profit > maximum_profit else maximum_profit
print(maximum_profit)

if debug:print((time.time() - start))
# Original solution
debug = False

if debug:import time
if debug:start = time.time()

n = int(eval(input()))
R = [0]*n
R_min = 10**9

R = [int(eval(input())) for i in range(n)]

maximum_profit = -10**9
for i in range(1, n):
    R_min = R[i-1] if R[i-1] < R_min else R_min
    profit = R[i] - R_min
    maximum_profit = profit if profit > maximum_profit else maximum_profit
print(maximum_profit)

if debug:print((time.time() - start))

# Optimized solution
n = int(eval(input()))

maximum_profit = -10**9
r0 = int(eval(input()))
r_min = r0
for i in range(1, n):
    r1 = int(eval(input()))
    if r0 < r_min:
        r_min = r0
    profit = r1 - r_min
    if profit > maximum_profit:
        maximum_profit = profit
    r0 = r1
print(maximum_profit)
# Original solution
n = int(eval(input()))
R = [int(eval(input())) for i in range(n)]
maxv = R[1] - R[0]

for i in range(0, n-1):
    for j in range(i+1, n):
        maxv = R[j] - R[i] if R[j] - R[i] > maxv else maxv

print(maxv)

# Optimized solution
n = int(eval(input()))
R = [int(eval(input())) for i in range(n)]
maxv = R[1] - R[0]
minv = R[0]

for j in range(1, n):
    maxv = R[j] - minv if R[j] - minv > maxv else maxv
    minv = R[j] if R[j] < minv else minv

print(maxv)
# Original solution
def max_benefit(num_list):
    max_num = 10**9*-1
    min_num = num_list[0]

    for i in range(1,len(num_list)):
        max_num = max(max_num,num_list[i]-min_num)
        min_num = min(num_list[i],min_num)
    return max_num

n = int(eval(input()))
num_list = []
for _ in range(n):
    num_list.append(int(eval(input())))

ans = max_benefit(num_list)
print(ans)


# Optimized solution
n = int(eval(input()))
num_list = [int(eval(input())) for _ in range(n)]
max_num = 10**9*-1
min_num = num_list[0]

for i in range(1,len(num_list)):
    max_num = max(num_list[i]-min_num,max_num)
    min_num = min(num_list[i],min_num)

print(max_num)
# Original solution
N = eval(input())
nums = []
for i in range(N):
     nums.append(eval(input()))

profit = nums[1] - nums[0]
for a in range(N):
     for b in range(a):
          if (nums[a] - nums[b]) > profit:
               profit = nums[a] - nums[b]

print(profit)

# Optimized solution
N = eval(input())
nums = []
for i in range(N):
     nums.append(eval(input()))
profit = nums[1] - nums[0]
min = nums[0]
for a in range(1, N):
     if nums[a] - min > profit:
          profit = nums[a] - min

     if nums[a] < min:
               min = nums[a]
print(profit)
# Original solution
N = int(eval(input()))
R = [int(eval(input())) for _ in range(N)]

ret = R[1] - R[0]
for i in range(N - 1):
    tmp = max(R[i + 1:]) - R[i]
    if tmp > ret:
        ret = tmp
print(ret)

# Optimized solution
N = int(eval(input()))
R = [int(eval(input())) for _ in range(N)]

p_buy = R[0]
p_sale = R[1]
buy = R[1]
sale = None
for i in range(2, N):
    if p_sale < R[i]:
        p_sale = R[i]
    if buy > R[i]:
        if sale is None:
            sale = R[i]
        if p_sale - p_buy < sale - buy:
            p_sale, p_buy = sale, buy 
        sale, buy = None, R[i]
    else:
        if sale is None or sale < R[i]:
            sale = R[i]

p_gain = p_sale - p_buy
print((p_gain if sale is None else max(p_gain, sale - buy)))
# Original solution
n = eval(input())
maxv = - 1 * pow(10, 9)
minv = eval(input())
for _ in range(1, n):
    Rj = eval(input())
    maxv = max(maxv, Rj - minv)
    minv = min(minv, Rj)

print(maxv)

# Optimized solution
import sys

n = eval(input())
minv = eval(input())
maxv = - 1000000000
nums = list(map(int, sys.stdin.readlines()))
for num in nums:
    maxv = num - minv if num - minv > maxv else maxv
    minv = num if num < minv else minv

print(maxv)
# Original solution
import math
A = []
N = int(eval(input()))
maxdiff = 0
for n in range(N):
    A.append(int(eval(input())))
S = tuple(A)
Smax = ((S[i]-min(S[:i])) for i in range(1, N))
print((max(Smax)))

# Optimized solution
import math
A = []
N = int(eval(input()))
maxdiff = 0
for n in range(N):
    A.append(int(eval(input())))
R = tuple(A)

Dmax = R[1] -R[0]
Rmin = R[0]

for i in range(1, N):
    if R[i] >= R[i-1]:
        if R[i] - Rmin > Dmax:
            Dmax = R[i] -Rmin
    if R[i] < Rmin:
        Rmin = R[i]
#    print(R[i], Dmax, Rmin)

print(Dmax)
# Original solution
ans = -float('inf')
n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        ans = max(a[j]-a[i], ans)
print(ans)

# Optimized solution
n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
minr = a[0]
ans = -float('inf')
for i in range(1, n):
    ans = max(a[i]-minr, ans)
    minr = min(a[i], minr)
print(ans)
# Original solution
R = [0 for i in range(0,200000)] 
n = int(input())
for i in range(n):
	R[i] = int(eval(input()))
maxv = -2000000000
minv = R[0]
for j in range(1, n):
	maxv = max(maxv, R[j]-minv)
	minv = min(minv, R[j])
print(maxv) 

# Optimized solution
n = int(input())
R = [eval(input()) for i in range(n)]
maxv = -2000000000
minv = R[0]
for j in range(1, n):
	maxv = max(maxv, R[j]-minv)
	minv = min(minv, R[j])
print(maxv)
# Original solution
from collections import deque


def main():
    d = deque()
    for _ in range(int(eval(input()))):
        d.append(int(eval(input())))
    
    result = min(d) - max(d)

    while d:
        c = d.popleft()
        if not d:
            break

        if max(d) - c > result:
            result = max(d) - c
    
    print(result)



if __name__ == '__main__':
    main()


# Optimized solution
def main():
    r = []
    for _ in range(int(eval(input()))):
        r.append(int(eval(input())))

    n = len(r)
    maxv = -20000000000
    minv = r[0]

    for i in range(1, n):
        maxv = max([maxv, r[i] - minv])
        minv = min([minv, r[i]])
    
    print(maxv)


if __name__ == '__main__':
    main()
# Original solution
n = int(eval(input()))
R = [int(eval(input())) for x in range(n)]
maxv = -2000000000

for j in range(1, n):
    for i in range(j):
        maxv = max(maxv, R[j] - R[i])

print(maxv)

# Optimized solution
n = int(eval(input()))
r = [int(eval(input())) for x in range(n)]
maxv = -2000000000
minv = r[0]

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

print(maxv)
# Original solution
n = int( eval(input( )) )

mi = int( eval(input( )) )
profit = 0 - 1000000000

for i in range( n-1 ):
	num = int( eval(input( )) )
	
	diff = num - mi
	if profit < diff:
		profit = diff

	if num < mi:
		mi = num

print( profit )
		

# Optimized solution
n = int( input( ) )

mi = int( input( ) )
profit = 0 - 1000000000
n -= 1
i = 0
while i < n:
	num = int( input( ) )
	
	diff = num - mi
	if profit < diff:
		profit = diff

	if num < mi:
		mi = num
	i += 1

print( profit )
# Original solution
N = int(eval(input()))
R = []
for i in range(N):
    R.append(int(eval(input())))

mprof = R[1] - R[0]
for i in range(1, len(R)):
    for k in range(i):
        if mprof < (R[i] - R[k]):
            mprof = (R[i] - R[k])

print(mprof)

# Optimized solution
N = int(eval(input()))
R = []
for i in range(N):
    R.append(int(eval(input())))

maxv = R[1] - R[0]
minv = R[0]
for i in range(1, len(R)):
        maxv = max(maxv, (R[i] - minv))
        minv = min(minv, R[i])

print(maxv)
# Original solution
n = int(eval(input()))
Rt = [eval(input()) for i in range(n)]
benef = int(Rt[1]) - int(Rt[0])

for i in range(n):
    for j in range(i+1,n):
      rate = int(Rt[j])-int(Rt[i])
      if rate > benef:
       benef = rate

print(benef)

# Optimized solution
n = int(eval(input()))

rt = [eval(input()) for i in range(n)]

minv = int(rt[0])
maxv = int(rt[1]) - int(rt[0])

for j in range(1,n):
    maxv = max(maxv,int(rt[j]) - minv)
    minv = min(minv,int(rt[j]))

print(maxv)
# Original solution
n = int(eval(input()))
r = [None] * n
min = 10**10
max = -10**10
for i in range(n):
    r[i] = int(eval(input()))

for i in range(n):
    if min > r[i]:
        min = r[i]
        for j in range(i+1,n):
            if max < r[j] - min:
                max = r[j] - min
print(max)

# Optimized solution
n = int(eval(input()))
minv = int(eval(input()))
maxv = (10**9)*(-1)
for j in range(1,n):
    r = int(eval(input()))
    if maxv < (r - minv):
        maxv = r - minv
    if minv > r:
        minv = r
print(maxv)
# Original solution
import sys

count=int(eval(input()))-1
input_list=[ int(i) for i in sys.stdin.readlines() ]

first=0
second=1
max_price_diff=input_list[second]-input_list[first]

for i in input_list[first:count]:
    for j in input_list[second:count+1]:
        if j-i > max_price_diff:
            max_price_diff=j-i
    second=second+1

print(max_price_diff)


# Optimized solution
import sys

count=int(eval(input()))
input_list=[ int(i) for i in sys.stdin.readlines() ]

first=0
second=1
maxv=-1000000000
minv=input_list[first]

for i in input_list[second:]:
    if i-minv > maxv:
        maxv=i-minv
    if i < minv:
        minv=i

print(maxv)
# Original solution
import sys

a = []
b = []
for line in sys.stdin:
    a.append(int(line))
    b.append(int(line))

del a[0]
del a[len(a)-1]
del b[0]
del b[0]

list = []
for i in range(len(a)):
    for j in range(len(b)):
        if j >= i:
            sub = b[j]-a[i]
            list.append(sub)
print((max (list)))


# Optimized solution
import sys

a = []
b = []
for line in sys.stdin:
    a.append(int(line))
    b.append(int(line))

del a[0]
del a[len(a)-1]
del b[0]
del b[0]

sub = -10000000000000
for i in range(len(a)):
    for j in range(len(b)):
        if j >= i:
            if sub <= b[j]-a[i]:
                sub = b[j]-a[i]
print(sub)
# Original solution
import sys

a = []
b = []
for line in sys.stdin:
    a.append(int(line))
    b.append(int(line))

del a[0]
del a[len(a)-1]
del b[0]
del b[0]

sub = -100000000000
for i in range(len(a)):
    for i in range(len(a)):
        for j in range(len(a)-i):
            if sub <= b[i+j]-a[i]:
                sub = b[i+j]-a[i]
print(sub)


# Optimized solution
import sys

a = []
b = []
for line in sys.stdin:
    a.append(int(line))
    b.append(int(line))

del a[0]
del a[len(a)-1]
del b[0]
del b[0]

sub = -100000000000
for i in range(len(a)):
    for j in range(len(b)):
        if j >= i:
            if sub <= b[j]-a[i]:
                sub = b[j]-a[i]
print(sub)
# Original solution
import sys

a = []
b = []
for line in sys.stdin:
    a.append(int(line))
    b.append(int(line))

del a[0]
del a[len(a)-1]
del b[0]
del b[0]

maxlist = []
for i in range(len(a)):
    list = []
    for j in range(len(b)):
        if j >= i:
            list.append(b[j]-a[i])
    maxlist.append(max(list))
print((max(maxlist)))




# Optimized solution
import sys

a = []
b = []
for line in sys.stdin:
    a.append(int(line))
    b.append(int(line))

del a[0]
del a[len(a)-1]
del b[0]
del b[0]

sub = -1000000000
for i in range(len(a)):
    for j in range(len(b)):
        if j >= i:
            if sub <= b[j]-a[i]:
                sub = b[j]-a[i]
print(sub)
# Original solution
import sys

a = []
b = []
for line in sys.stdin:
    a.append(int(line))
    b.append(int(line))

del a[0]
del a[len(a)-1]
del b[0]
del b[0]

sub = -1000000000
for i in range(len(a)):
    for j in range(len(b)):
        if j >= i:
            sub = max(sub,b[j]-a[i])
print(sub)




# Optimized solution
import sys

a = []
b = []
for line in sys.stdin:
    a.append(int(line))
    b.append(int(line))

del a[0]
del a[len(a)-1]
del b[0]
del b[0]

maxv = -1000000000
minv = a[0]
for i in range(len(a)):
    maxv = max(maxv,b[i]-minv)
    minv = min(minv,b[i])
print(maxv)
# Original solution
mini = pre = float("inf")
def f(n):
    global mini, pre
    mini = min(mini, pre)
    pre = n
    return n - mini
print(max(f(eval(input())) for _ in range(eval(input()))))

# Optimized solution
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(eval(input())) for _ in range(int(eval(input())))]
    print((maximum_profit(R)))
# Original solution

n = int(eval(input()))
arr = [0] * n
for i in range(n):
	arr[i] = int(eval(input()))

max_profit = arr[1] - arr[0]
min_price = arr[0]
for i in range(1, n):
	current = arr[i]
	max_profit = max(max_profit, current - min_price)
	min_price = min(min_price, current)

print(max_profit)


# Optimized solution
n = int(eval(input()))

n0 = int(eval(input()))
n1 = int(eval(input()))
max_profit = n1 - n0
min_price = min(n0, n1)
for i in range(n - 2):
	current = int(eval(input()))
	max_profit = max(max_profit, current - min_price)
	min_price = min(min_price, current)

print(max_profit)
# Original solution
n = eval(input())
m = [0] * n
max = [0] * n
kijun = [0] * n
rieki = [0] * n
max_rieki = -1*10**9


for i in range(n):
 m[i] = eval(input())
 
 
for i in range(n):
 if i != n-1:    
  for j in range(i+1,n): 
   if max_rieki < m[j] - m[i]:
      max_rieki = m[j] - m[i]


print(max_rieki)

# Optimized solution
n = eval(input())
m = [0] * n
max_rieki = -1000000000



for i in range(n):
 m[i] = eval(input())

min_rieki = m[0]
for i in range(1,n): 
  if max_rieki < m[i] - min_rieki:
     max_rieki = m[i] - min_rieki
  if min_rieki > m[i]:
     min_rieki = m[i]

print(max_rieki)
# Original solution
n = int(eval(input()))
L =[]
for i in range(n):
    x = int(eval(input()))
    L.append(x)

m = L[1]-L[0]

for x in range(n-1):

    for i in range(x,n-1):

        if m <= L[i+1]-L[x]:
            m = L[i+1]-L[x]
        else:
            pass

print (m)

# Optimized solution
n = int(eval(input()))
L =[]
for i in range(n):
    x = int(eval(input()))
    L.append(x)

m = L[1]-L[0]

for x in range(n-1):

    for i in range(x,n-1):
        m = max([m,L[i+1]-L[x]])

print (m)
# Original solution
import sys

x = []

for line in sys.stdin.readlines():
    x.append(int(line.strip()))

length = int(x[0])

del x[0]

max = -(10 ** 9)

for i in range(0, length - 1):
    for j in range(i + 1, length):
        sa = int(x[j]) - int(x[i])
        if max < sa:
            max = sa

print(max)

# Optimized solution
import sys

x = []

for line in sys.stdin.readlines():
    x.append(int(line.strip()))

length = int(x[0])

del x[0]

max = -(10 ** 9)
min =  x[0]

for i in range(1, length):
    sa = x[i] - min

    if sa > max:
        max = sa

    if x[i] < min:
        min = x[i]
   
print(max)
# Original solution
a=eval(input())
r=[]
for i in range(a):
    k=eval(input())
    r.append(k)
minn=-10**9
for i in range(len(r)):
    for j in range(i+1,len(r)):
        k=r[j]-r[i]
        if k>minn:
            minn=k
print(minn)

# Optimized solution
a=eval(input())
r=[]
for i in range(a):
    k=eval(input())
    r.append(k)
minv=r[0]
maxv=-10**9
for j in range(1,len(r)):
    maxv=max(maxv,r[j]-minv)
    minv=min(minv,r[j])
print(maxv)
# Original solution
from _collections import deque

_temp = deque([])
my_max = []

size = int(input().rstrip())
for i in range(size):
    try:
        _temp.append(int(eval(input())))
    except EOFError:
        continue



for val in list(_temp)[:-1]:
    v = _temp.popleft()
    my = max(_temp) - v

    if len(my_max) == 0:
        my_max.append(my)
    else:
        if my > max(my_max):
            my_max.append(my)

print((max(my_max)))

# Optimized solution
_temp = []

size = int(input().rstrip())
for i in range(size):
    try:
        _temp.append(int(eval(input())))
    except EOFError:
        continue

my_max = -20000000000000
my_min = _temp.pop(0)


for val in _temp:
    my_max = max(my_max, (val - my_min))
    my_min = min(my_min, val)

print(my_max)
# Original solution
import sys

# ?????§???????±??????????
def get_max(data):
    now_max = None
    for i in range(0, len(data)-1):
        start_val = data[i]
        for j in range(i+1, len(data)):
            if now_max is None or data[j]-start_val > now_max:
                now_max = data[j] - start_val
    return now_max

# ??\???????????????????????????
data = []
line_num = int(sys.stdin.readline().rstrip())
while True:
    input_data = sys.stdin.readline()
    if not input_data:
        break
    input_data = int(input_data.rstrip())
    data.append(input_data)

result = get_max(data)
print(result)

# Optimized solution
import sys

line_num = int(sys.stdin.readline().rstrip())
maxv = -2000000000
minv = int(sys.stdin.readline().rstrip())

for i in range(1, line_num):
    rt = int(sys.stdin.readline())
    if rt - minv > maxv:
        maxv = rt - minv
    if rt < minv:
        minv = rt

print(maxv)