CodeEff/ECCO huggingface dataset:
# Original solution
n = eval(input())
n = int(n)

price_list = []

x = eval(input())
x = int(x)

price_list.append(x)

max_profit_candidate = 1 - 10**9

for i in range(n - 1):
    x = eval(input())
    x = int(x)
    diff = x - min(price_list)
    if diff > max_profit_candidate:
        max_profit_candidate = diff
    price_list.append(x)

print(max_profit_candidate)

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

x = eval(input())
x = int(x)

present_min_value = x
max_profit_candidate = 1 - 10**9

for i in range(n - 1):
    a = eval(input())
    a = int(a)
    diff = a - present_min_value
    if diff > max_profit_candidate:
        max_profit_candidate = diff
    if a < present_min_value:
        present_min_value = a

print(max_profit_candidate)
# Original solution
from collections import defaultdict
import math




if __name__ == '__main__' :
    n = int(eval(input()))
    R = [int(eval(input())) for i in range(n)]
    tmp = [max(R[i+1::])  - R[i] for i in range(n-1)]
    print((max(tmp)))



# Optimized solution
from collections import defaultdict
import math




if __name__ == '__main__' :
    n = int(eval(input()))
    R = [int(eval(input())) for i in range(n)]
    maxv = R[1]-R[0]
    minv = min(R[0],R[1])
    for j in range(2,n):
        maxv = max(maxv,R[j]-minv)
        minv = min(minv,R[j])
    print(maxv)
# Original solution
n = int(eval(input()))
prices = [int(eval(input())) for i in range(n)]
ans = 1 - (10 ** 9)
for x in range(n-1):
    for y in range(x+1, n):
        ans = max(ans, prices[y] - prices[x])
print(ans)



# Optimized solution
n = int(eval(input()))
min_v = int(eval(input()))
ans = 1 - min_v
for i in range(1, n):
    j = int(eval(input()))
    ans = max(ans, j - min_v)
    min_v = min(min_v, j)
print(ans)
# Original solution
N = int(eval(input()))
a = []

for i in range(N):
	a.append(int(eval(input())))

max_dist = -10e10

for i in range(N-1):
	for j in range(i + 1, N):
		if a[j] - a[i] > max_dist:
			max_dist = a[j] - a[i]

print(max_dist)


# Optimized solution
N = int(eval(input()))
a = []

for i in range(N):
	a.append(int(eval(input())))

maxv = -10e10
minv = a[0]

for i in range(1, N):
	maxv = a[i] - minv if maxv < a[i] - minv else maxv
	minv = a[i] if minv > a[i] else minv

print(maxv)
# Original solution
#import time

N = int(eval(input()))
datas = [int(eval(input())) for _ in range(N)]
#start = time.time()
now_max = max(datas[1:])
max_index = datas.index(now_max)
diff = now_max - datas[0]

for i in range(1,N-1):
    if i == max_index:
        d = datas[i+1:]
        now_max = max(d)
        max_index = d.index(now_max)+i+1
    new_diff = now_max - datas[i]
    if diff < new_diff:
        diff = new_diff

print(diff)
#print('time :',time.time()-start)


# Optimized solution
#import time

N = int(eval(input()))
datas = [int(eval(input())) for _ in range(N)]
#start = time.time()
now_max = max(datas[1:])
max_index = datas.index(now_max)
diff = now_max - datas[0]

for i in range(1,N-1):
    if i == max_index:
        now_max = max(datas[i+1:])
        max_index = datas.index(now_max,i+1)
    new_diff = now_max - datas[i]
    if diff < new_diff:
        diff = new_diff

print(diff)
#print('time :',time.time()-start)
# Original solution
from sys import stdin

N,*datas = [int(i) for i in stdin.readlines()]
now_max = max(datas[1:])
max_index = (N-1) - list(reversed(datas)).index(now_max)
_min = min(datas)
min_index = datas.index(_min)

if max_index > min_index:
    diff = now_max - _min
else:
    diff = now_max - datas[0]
    
    for i in range(1,N-1):
        if i == max_index:
            now_max = max(datas[i+1:])
            max_index = datas.index(now_max,i+1)
        new_diff = now_max - datas[i]
        if diff < new_diff:
            diff = new_diff

print(diff)


# Optimized solution
from sys import stdin

N,*datas = [int(i) for i in stdin.readlines()]
now_max = max(datas[1:])
max_index = datas.index(now_max)
diff = now_max - datas[0]

for i in range(1,N-1):
    if i == max_index:
        now_max = max(datas[i+1:])
        max_index = datas.index(now_max,i+1)
    new_diff = now_max - datas[i]
    if diff < new_diff:
        diff = new_diff

print(diff)
# Original solution
n = int(input())

R = [0 for i in range(n)]

ans = 1 - 10**9
for i in range(n):
    R[i] = int(input())
    if i == 0:
        min_R = R[0]
        continue
    if R[i] - min_R > ans:
        ans = R[i] - min_R
    if R[i] < min_R:
        min_R = R[i]
        
print(ans)
    
    
    

# Optimized solution
n = int(input())

R = [0 for i in range(n)]

ans = 1 - 10**9
min_R = int(input())
for i in range(n-1):
    R[i] = int(input())
    if R[i] - min_R > ans:
        ans = R[i] - min_R
    if R[i] < min_R:
        min_R = R[i]
        
print(ans)
# Original solution
amount = int(eval(input()))

numbers = [int(eval(input())) for i in range(amount)]

max_profit = -1 * (numbers[0] - numbers[1])

for i in range(amount - 1):
    for j in range(i + 1, amount):
        if (-1 * (numbers[i] - numbers[j])) >= max_profit:
            max_profit = -1 * (numbers[i] - numbers[j])

print(max_profit)

# Optimized solution
maxv = -2 * 10 ** 9
minv = 2 * 10 ** 9

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

print(maxv)
# Original solution
# -*- coding: utf-8 -*-

n = int(input())
R_List = []
Max = 0
for i in range(n):
    R_List.append(int(input()))
    if i == 0:
        continue
    elif i == 1:
        Max = R_List[1]-R_List[0]
    else:
        for j in range(i):
            Max = max(Max, R_List[i]-R_List[j])
print(Max)

# Optimized solution
# -*- coding: utf-8 -*-

n = int(input())
R_List = []
Max = 0
R_min = 0
for i in range(n):
    R_List.append(int(input()))
    if i == 0:
        R_min = R_List[0]
    elif i == 1:
        Max = R_List[1]-R_min
        R_min = min(R_min, R_List[1])
    else:
        Max = max(Max, R_List[i]-R_min)
        R_min = min(R_min, R_List[i])
print(Max)
# Original solution
n = int(eval(input()))

t = []

for i in range(n):
    t.append(int(eval(input())))

buy = t[0]
prev_sell = max(t[1:])
val = prev_sell - buy

for i in range(n-1):
    if i == 0 or t[i - 1] < t[i]:
        continue
    prev_sell = max(t[i+1:])
    val2 = prev_sell - t[i]
    if val2 > val:
        val = val2

print(val)



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

t = []

for i in range(n):
    t.append(int(eval(input())))

buy = t[0]
val = t[-1] - buy

for i in range(1, n):
    if t[i] - buy > val:
        val = t[i] - buy
    if t[i] < buy:
        buy = t[i]

print(val)
# Original solution
import sys
n=int(eval(input()))
r=list(map(int,sys.stdin.read().split()))
print((max([max(r[i+1:])-r[i]for i in range(n-1)])))

# Optimized solution
n=int(eval(input()))
r=[int(eval(input()))for _ in range(n)]
s=r[0];b=r[1]-s
for i in range(1,n):
 b=max(b,r[i]-s)
 s=min(s,r[i])
print(b)
# Original solution
import sys
b,s=-1e10,1e10
eval(input())
for r in map(int,sys.stdin):
 if b<r-s:b=r-s
 if s>r:s=r
print(b)


# Optimized solution
import sys
s=1e10;b=-s
eval(input())
for r in map(int,sys.stdin):
 if b<r-s:b=r-s
 if s>r:s=r
print(b)
# Original solution
import sys
s=1e10;b=-s
eval(input())
for r in map(int,sys.stdin.readlines()):
 if b<r-s:b=r-s
 if s>r:s=r
print(b)


# Optimized solution
import sys
def m():
 s=1e10;b=-s
 eval(input())
 for r in map(int,sys.stdin):
  if b<r-s:b=r-s
  if s>r:s=r
 print(b)
if'__main__'==__name__:m()
# Original solution
import sys
s=1e10;b=-s
eval(input())
for r in map(int,sys.stdin):
 if b<r-s:b=r-s
 if s>r:s=r
print(b)


# Optimized solution
import sys
def f():
 s=1e10;b=-s
 eval(input())
 for r in map(int,sys.stdin):
  if b<r-s:b=r-s
  if s>r:s=r
 print(b)
f()
# Original solution
n=int(eval(input()))
Rt=[]
for i in range(n):
	Rt.append(int(eval(input())))

a=-999999999
for i in range(1,n):
	for j in range(i):
		if a<Rt[i]-Rt[j]:
			a=Rt[i]-Rt[j]
		
print(a)


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

maxv=Rt[1]-Rt[0]
minv=Rt[0]
for j in range(1,n):
	maxv=max(maxv,Rt[j]-minv)
	minv=min(minv,Rt[j])
		
print(maxv)
# Original solution
N = int(eval(input()))

purchase_price = int(eval(input()))
profit = -2000000000
for _ in range(N-1):
    price = int(eval(input()))
    profit = max(profit, (price-purchase_price))
    purchase_price = min(price, purchase_price)

print(profit)


# Optimized solution
N = int(eval(input()))
r1 = int(eval(input()))
r2 = int(eval(input()))
R = [int(eval(input())) for i in range(N-2)]

res = r2 - r1
min_r = min(r1, r2)

for r in R:
  res = max(res, r - min_r)
  min_r = min(min_r, r)

print(res)
# Original solution
N =int(eval(input()))
R = []
for i in range(N):
        R.append(int(eval(input())))
maxv=-2000000000
minv=R[0]
for i in range(1,N):
    maxv=max(maxv,R[i]-minv)
    minv=min(minv,R[i])
print(maxv)

# Optimized solution
import sys
i=input
n =int(i())
r0=int(i())
r1=int(i())
maxv=r1-r0
minv=min(r1,r0)
for i in map(int,sys.stdin.readlines()):
    maxv=max(maxv,i-minv)
    minv=min(minv,i)
print(maxv)
# Original solution
#16D8101012J 伊藤惇 dj Python3
import sys

def Maximum_Profit(n,A):
    Max=-sys.maxsize
    for i in range(n-1):
        tmp=(max(A[i+1:])-A[i])
        if Max<tmp:
            Max=tmp
    return Max

if __name__ == "__main__":
    n=int(eval(input()))
    A=[]
    for i in range(n):
        A.append(int(eval(input())))
    Max=Maximum_Profit(n,A)
    print(Max)



# Optimized solution
#16D8101012J 伊藤惇 dj Python3

def Maximum_Profit(n,A):
    Max=A[1]-A[0]
    Min=A[0]
    for j in range(1,n):
        Max=max(Max,A[j]-Min)
        Min=min(Min,A[j])
    return Max

if __name__ == "__main__":
    n=int(eval(input()))
    A=[]
    for i in range(n):
        A.append(int(eval(input())))
    Max=Maximum_Profit(n,A)
    print(Max)
# Original solution
n = int(input())
nums = [int(input()) for i in range(n)]

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

print(maxv)


# Optimized solution
# coding: utf-8
# 答えを見た。。。

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

maxv = -2000000000
minv = R[0]

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

print(maxv)
# Original solution
arr = []
for i in range(int(eval(input()))):
    arr.append(int(eval(input())))
m = 0
for i in range(len(arr)-1):
    for j in range(i+1, len(arr)):
        if i == 0 and j == 1:
            m = arr[j] - arr[i]
        else:
            m = max(m, arr[j] - arr[i])
print(m)   

# Optimized solution
n = int(eval(input()))
arr = [int(eval(input())) for i in range(n)]

m = 1 - 10**9
minv = arr[0]
for i in range(1,len(arr)):
    if arr[i] - minv > m:
        m = arr[i] - minv
    minv = min(minv, arr[i])
print(m)
# Original solution
r = []
N = int(eval(input()))
for i in range(0, N):
    r.append(int(eval(input())))

min = r[N-2]
max = r[N-1]

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

print((max - min))

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

min_i = N-2
max_i = N-1

for i in range(N-1)[::-1]:
    if (r[i] - r[i+1]) * r[max_i] - r[min_i] < 0:
        for j in range(i+1, N):
            if r[j] - r[i] > r[max_i] - r[min_i]:
                max_i = j
                min_i = i

                
print((r[max_i] - r[min_i]))
# Original solution
r = []
N = int(eval(input()))
for i in range(0, N):
    r.append(int(eval(input())))

min_i = N-2
max_i = N-1

for i in range(N-1)[::-1]:
    if r[i] < r[i+1]:
        for j in range(i+1, N):
            if r[j] - r[i] > r[max_i] - r[min_i]:
                max_i = j
                min_i = i
    if r[max_i] - r[min_i] < 0:
        if r[i+1] - r[i] > r[max_i] - r[min_i]:
            max_i = i+1
            min_i = i

                
print((r[max_i] - r[min_i]))

# Optimized solution
N = int(eval(input()))
r = [int(eval(input())) for i in range(N)]
 
min = r[0]
max = -9999999999999999
 
for i in range(1, N):
    if r[i] - min > max:
        max = r[i] - min
    if r[i] < min:
        min = r[i]
 
print(max)
# Original solution
import sys

def solve():
    n = int(input())
    R = []

    for i in range(n):
        R.append(int(input()))

    #for i in xrange(n):
    #    print R[i]

    max_profit = -sys.maxsize
    for i in range(n):
        for j in range(i + 1, n):
            if R[j] - R[i] > max_profit:
                max_profit = R[j] - R[i]


    print(max_profit)


if __name__ == "__main__":
    solve()

# Optimized solution
import sys

def solve():
    n = int(input())
    R = []

    for i in range(n):
        R.append(int(input()))

    #for i in xrange(n):
    #    print R[i]

    max_profit = -sys.maxsize
    min_R = R[0]

    for i in range(1, n):
        if R[i] - min_R > max_profit:
            max_profit = R[i] - min_R
        if min_R > R[i]:
            min_R = R[i]

    print(max_profit)


if __name__ == "__main__":
    solve()
# Original solution
num = n = int(eval(input()))
price = []
max_profit = -999999999999999

while(n>0):
    x = int(eval(input()))
    price.append(x)
    n -= 1
for i in range(1,num):
    for n in range(0,i):
        pro = price[i] - price[n]
        if pro > max_profit:
            max_profit = pro

print(("{0}".format(max_profit)))

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

price = []
max_pro = -999999999

while(n>0):
    x = int(eval(input()))
    price.append(x)
    n -= 1
min = price[0]
for i in range(1,num):
    pro = price[i]-min

    if(max_pro < pro):
        max_pro = pro
    if(min > price[i]):
        min = price[i]
print(("{0}".format(max_pro)))
# Original solution
n = eval(input())
n = int(n)

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

l = []
for i, p in enumerate(pl[:-1]):
    l.append(max(pl[i+1:])-p)

m = max(l)
print(m)

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

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

m = pl[0]
M = pl[0]
difM = pl[1]-pl[0]

for i, p in enumerate(pl[1:]):
    if p < m: 
        m = p
        continue
    if p - m > difM:
        difM = p - m

print(difM)
# Original solution
n = int(eval(input()))
a = []
for i in range(n):
  a.append(int(eval(input())))
ans = a[1]-a[0]
for i in range(n-1):
  k = max(a[i+1:]) - a[i]
  if k > ans:
      ans =  k
print(ans)



# Optimized solution
n = int(eval(input()))
a = []
for i in range(n):
  a.append(int(eval(input())))
nowmin = a[0]
ans = a[1]-a[0]
for i in range(n-1):
  if a[i] <= nowmin:
    k = max(a[i+1:]) - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]
    
print(ans)
# Original solution
n = int(eval(input()))
a = []
for i in range(n):
  a.append(int(eval(input())))
nowmin = a[0] + 1
ans = a[1]-a[0]
for i in range(n-1):
  if a[i] < nowmin:
    k = max(a[i+1:]) - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]
    
print(ans)



# Optimized solution
n = int(eval(input()))
a = []
for i in range(n):
  a.append(int(eval(input())))
nowmin = a[0]
nowmax = max(a[1:])
ans = nowmax - nowmin
for i in range(n-1):
  if a[i] == nowmax:
    nowmax = max(a[i+1:])
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]


print(ans)
# Original solution
N = eval(input())
N = int(N)
l = [int(eval(input())) for i in range(N)]
flg = 1
ma = 0
for i in range(0,len(l)-1):
    for j in range(i+1,len(l)):
        if(ma < l[j]-l[i] or flg ==1):
            ma = l[j] - l[i]
            flg = 0
print(ma)


# Optimized solution
N = eval(input())
N = int(N)
l = [int(eval(input())) for i in range(N)]
flg = 1
ma = 0
mi = 0
for i in range(1,len(l)):
    if(mi > l[i-1] or flg ==1):
        mi = l[i-1]
    if(ma < l[i] - mi or flg ==1):
        ma = l[i] - mi
        flg = 0
print(ma)
# Original solution
cnt = int(eval(input()))
v = []

for i in range(cnt):
    v.append(int(eval(input())))

len = len(v)
dif_max = -1000000000

for i in range(len):
    for j in range(i + 1, len, 1):
        dif = v[j] - v[i]
        dif_max = dif if dif_max < dif else dif_max

print(dif_max)

# Optimized solution
cnt = int(eval(input()))
dif_max = -1000000000
v_min = 1000000000

for i in range(cnt):
    buf = int(eval(input()))
    if i > 0:
        dif_max = dif_max if buf - v_min < dif_max else buf - v_min
    v_min = buf if buf < v_min else v_min
print(dif_max)
# Original solution
x = int(eval(input()))
l=[]
for i in range(x):
    l.append(int(eval(input())))
max_ = -99999999999999999999999
for i, v1 in enumerate(l):
    for j, v2 in enumerate(l):
        if j > i:
            if v2-v1 > max_:
                max_ = v2-v1
print(max_)

# Optimized solution
x = int(eval(input()))
l=[]
for i in range(x):
    l.append(int(eval(input())))
MIN = 999999999999999999999999999999999999999
MAX = -9999999999999999999999999999999999999
for i in l:
    if i - MIN > MAX:
        MAX = i - MIN
    if i < MIN:
        MIN = i
print(MAX)
# Original solution
n = int(eval(input()))
ls = [int(eval(input())) for _ in range(n)]

p = min(ls) - max(ls)

for i, x in enumerate(ls, 1):
    if i == len(ls):
        break
    v = max(ls[i:]) - x
    if v > p:
        p = v
print(p)


# Optimized solution
n = int(eval(input()))
m = [int(eval(input())) for _ in range(n)]

def fx(raw):
    min_n = raw[0]
    max_n = raw[1] - raw[0]
    for i in raw[1:]:
        if i - min_n >= max_n:
            max_n = i - min_n
        if i < min_n:
            min_n = i
    return max_n


if __name__ == '__main__':
    print((fx(m)))
# Original solution
def set_values():
	values = []
	for i in range(int(eval(input()))):
		values.append(int(eval(input())))
	return values

def check_all(values):
	max_value = min(values) - max(values)
	for i in range(len(values)-1):
		count = i + 1
		max_value = get_max_value(i, len(values), count, max_value)
	return max_value

def get_max_value(now_index, length, count, max_value):

	while count < length:
		if max_value < (values[count] - values[now_index]):
			max_value = (values[count] - values[now_index])
		count += 1
	return max_value

values = set_values()
max_value = check_all(values)
print(max_value)


# Optimized solution
def set_values():
	values = []
	for i in range(num):
		values.append(int(eval(input())))
	return values

num = int(eval(input()))
values = set_values()
max_value = values[1] - values[0]
min_value = values[0]

for i in range(1, num):
	max_value = max(max_value, (values[i] - min_value))
	min_value = min(min_value, values[i])

print(max_value)
# Original solution
n=int(eval(input()))
R=[int(eval(input())) for i in range(n)]
mini=10**10
maxi=-10**10
for r in R:
    maxi=max([maxi,r-mini])
    mini=min([mini,r])
print(maxi)


# Optimized solution
N = int(eval(input()))
A = [int(eval(input())) for n in range(N)]
B, C = [], []
m = 10 ** 9
M = 0
for n in range(N):
    if A[n] < m:
        m = A[n]
    if A[N - n - 1] > M:
        M = A[N - n - 1]
    B.append(m)
    C.append(M)
C.reverse()
D = [C[n+1] - B[n] for n in range(N-1)]
print((max(D)))
# Original solution
n = int(eval(input()))
ps = [int(eval(input())) for _ in range(n)]
maxpro = -9999999999
for i, p in enumerate(ps[:-1]):
  pro = max(ps[i + 1:]) - p
  maxpro = max(pro, maxpro)
print(maxpro)

# Optimized solution
n = int(eval(input()))
ps = [int(eval(input())) for _ in range(n)]
maxpro = -999999999
minp = 1000000000
for i, p in enumerate(ps[:-1]):
  if p >= minp: continue
  pro = max(ps[i + 1:]) - p
  maxpro = max(pro, maxpro)
  minp = p
print(maxpro)
# Original solution
n = int(eval(input()))
R = [int(eval(input())) for _ in range(n)]
ans = R[1] - R[0]
bottom = min(R[0], R[1])
for r in R[2:]:
    ans = max(ans, r - bottom)
    bottom = min(bottom, r)
print(ans)

# Optimized solution
n = int(eval(input()))
R = [int(eval(input())) for _ in range(n)]
ans = R[1] - R[0]
bottom = min(R[0], R[1])
for r in R[2:]:
    ans = max(ans, r - bottom)
    if r < bottom:
        bottom = r
print(ans)
# Original solution
n = int(eval(input()))
a = [0]*n
for i in range(n):
    a[i] = int(eval(input()))

max = a[1]-a[0]
for i in range(2,n):
    for j in range(0,i):
        tmp = a[i]-a[j]
        if max<tmp:
            max = tmp

print(max)



# Optimized solution
n = int(eval(input()))
a = [0]*n
for i in range(n):
    a[i] = int(eval(input()))

max = a[1]-a[0]
min = a[0]
for i in range(1,n):
    if max < (a[i]-min):
        max = (a[i]-min)
    if min > a[i]:
        min = a[i]
        
print(max)
# Original solution
import sys

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

maxv = - sys.maxsize - 1

for c, i in enumerate(values):
    for j in values[c + 1:]:
        maxv = max(maxv, j - i)

print(maxv)


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


# Optimized solution
values = [int(eval(input())) for _ in range(int(eval(input())))]
maxv = values[1] - values[0]
minv = values[0]

for val in values[1:]:
    maxv = max(maxv, val - minv)
    minv = min(minv, val)
print(maxv)
# Original solution
t = []
n = int(eval(input()))
for i in range(n):
    t.append(int(eval(input())))



'''
n = 6
t=[4,1,5,7,5,4]
'''



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

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



'''
n = 6
t=[4,1,5,7,5,4]
'''


minv = t[0]
maxv = t[1] - t[0]
for j in range(1,n):
    maxv = max([maxv,t[j] - minv])
    minv = min([minv,t[j]])
print(maxv)
# Original solution
a = []
n = int(eval(input()))
for i in range(n):
    a.append(int(eval(input())))
print((max(max(a[i:])-min(a[:i]) for i in range(1, n))))

# Optimized solution
maxv = -2*10**9
minv = 2*10**9
n = int(eval(input()))
for i in range(n):
    x = int(eval(input()))
    maxv = max(x - minv, maxv)
    minv = min(x, minv)
print(maxv)
# Original solution
r = []

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

maxv = r[1] - r[0]

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

print(maxv)



# Optimized solution
'''
Rjの最小値を保持することで最大利益の更新判定をn回で終わらせる
'''

r = []

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

minv = r[0]
maxv = r[1] - r[0]

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

print(maxv)
# Original solution
# -*- coding: utf-8 -*-

import sys
import os
import math


N = int(eval(input()))
lst = []
for i in range(N):
    lst.append(int(eval(input())))

max_diff = lst[1] - lst[0]

for i in range(N):
    for j in range(i + 1, N):
        diff = lst[j] - lst[i]
        if diff > max_diff:
            max_diff = diff

print(max_diff)

# Optimized solution
# -*- coding: utf-8 -*-

import sys
import os
import math


N = int(eval(input()))
lst = []
for i in range(N):
    lst.append(int(eval(input())))

max_profit = lst[1] - lst[0]
min_value = min(lst[0], lst[1])

for i in range(2, N):
    price = lst[i]
    max_profit = max(max_profit, price - min_value)
    min_value = min(min_value, price)

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

candidate = [-float('inf')]
for i in range(1, len(stack) // 2 + 1):
    for r1, r2 in zip(stack[::1], stack[i::1]):
        candidate.append(r2 - r1)
    for r1, r2 in zip(stack[::1], stack[len(stack) - i::1]):
        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())))

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

print((candidate[0]))