https://www.acmicpc.net/problem/2846
n=input() n=int(n) s=list(map(int,input().split())) a=s[0] b=a max=0 for i in range(1,n): p=s[i] if p>b: b=p if b-a>max: max=b-a else: a=p b=a print(max)