n=int(input()) x=input().split() num=[] for a in x:
num.append(int(a))
Max=max(num)-min(num) print(Max)
参考:
n=int(input())
x=[int(i) for i in input().split()]
xl = len(x)
xm = [x[-1] for i in range(xl)]#从右往左最小值
for i in range(len(x)-2,-1,-1):
if x[i]<xm[i+1]:
xm[i] = x[i]
else:
xm[i] = xm[i+1]
#print(xm)
dmax=-1
for i in range(xl-1):
dtry = x[i]-xm[i+1]
if dtry > dmax:
dmax = dtry
print(dmax)