def main():from sys import stdinn=int(stdin.readline())s=list(map(int,stdin.readline().split()))ans=0while n!=1:mi=float('inf')idx=-1for i in range(1,n):ss=abs(s[i]-s[i-1])if mi>ss:mi=ssidx=ip=s.pop(idx)s[idx-1]+=pans+=min-=1print(ans)if __name__=="__main__":main()
考試交的答案