#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1010;
int a[N];
int main(){
int n;
while(cin >> n){
for(int i=0;i<n;i++){
cin >> a[i];
}
int res = 0;
for(int i=0,j=0;i<=n;i++){
j = i+1;
while(j<n && a[j] >= a[j-1]){ //注意!非下降序列,故取">="
j++;
}
res = max(res,a[j-1] - a[i]);
i = j-1; //下一次循环自动i++
}
cout << res << endl;
}
return 0;
}