include[HTML_REMOVED]
using namespace std;
const int N=1e5+10;
int a[N];
int main()
{
int n;
while(cin>>n)
{
for(int i=1;i<=n;i)
{
cin>>a[i];
}
int res=0;
int k=1,cnt=0;
while(k<n)
{
if(a[k]<=a[k+1])
{
cnt+=a[k+1]-a[k];
res=max(res,cnt);
}
else
{
cnt=0;
}
k;
}
cout<<res<<endl;
}
}