#include <stdio.h>
#define N 200000
int main(){
  int i,j,n,max;
  int a[N];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=n-1;i>=0;i--){
    for(j=0;j<i;j++){
      if(i==n-1 && j==0){
	max = a[i] - a[j];
      }
      else if(a[i]-a[j] > max){
	max = a[i] - a[j];
      }
    }
  }

  printf("%d\n",max);

  return 0;
}

