#include <bits/stdc++.h>
int main(void) {
  unsigned short usW_Delement_cnt;
  unsigned short usW_Dloop_cnt;
  unsigned long ulW_Delement;
  unsigned long ulW_Delement_min;
  signed long ulW_Delement_max = -2147483648;
  unsigned long ulW_Dcalc;
  scanf("%d", &usW_Delement_cnt);
  scanf("%ld", &ulW_Delement_min);
  for (usW_Dloop_cnt = 1; usW_Dloop_cnt < usW_Delement_cnt; usW_Dloop_cnt++) {
    scanf("%ld", &ulW_Delement);
    ulW_Dcalc = ulW_Delement - ulW_Delement_min;
    if (ulW_Delement_max < ulW_Dcalc) {
      ulW_Delement_max = ulW_Dcalc;
    } else {
    }
    if (ulW_Delement_min > ulW_Delement) {
      ulW_Delement_min = ulW_Delement;
    } else {
    }
  }
  printf("%ld\n", ulW_Delement_max);
  return 0;
}
