import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();
		int[] ary = getAryMl(breader);
		int maxdf = ary[1] - ary[0] ;
		for( int i = 0 ; i < ary.length ; i++ ) {
			int maxj = i+1;
			if ( maxj == ary.length ) break;
			int mini = i;
			for( int j = i+2 ; j < ary.length ; j++ ) {
				if ( ary[maxj] <= ary[j]) {
					maxj = j;
				}
			}
			for( int k = i+1 ; k < maxj ; k++ ) {
				if ( ary[k] < ary[mini]) {
					mini = k;
				}
			}
			int maxdfw = ary[maxj]- ary[mini];
			if ( maxdf < maxdfw) {
				maxdf = maxdfw ;
			}
			i = maxj;
		}
		System.out.println(maxdf);
		
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static int[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static int[] getAryMl(BufferedReader br)throws Exception {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	}
	public static void putAry(int[] ary, int num) {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}
	public static void putAry(int[] ary) {
		putAry(ary, ary.length ) ;
	}
	public static boolean isPrime(int n) {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();
		int[] ary = getAryMl(breader);
		int maxdf = ary[1] - ary[0] ;
		for( int i = 0 ; i < ary.length ; i++ ) {
			int maxj = i+1;
			if ( maxj == ary.length ) break;
			int mini = i;
			for( int j = i+2 ; j < ary.length ; j++ ) {
				if ( ary[maxj] <= ary[j]) {
					maxj = j;
				}
			}
			for( int k = i+1 ; k < maxj ; k++ ) {
				if ( ary[k] < ary[mini]) {
					mini = k;
				}
			}
			int maxdfw = ary[maxj]- ary[mini];
			if ( maxdf < maxdfw) {
				maxdf = maxdfw ;
			}
			i = maxj;
		}
		System.out.println(maxdf);
		
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static int[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static int[] getAryMl(BufferedReader br)throws Exception {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	}
	public static void putAry(int[] ary, int num) {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}
	public static void putAry(int[] ary) {
		putAry(ary, ary.length ) ;
	}
	public static boolean isPrime(int n) {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	}

} Main public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();
		int[] ary = getAryMl(breader);
		int maxdf = ary[1] - ary[0] ;
		for( int i = 0 ; i < ary.length ; i++ ) {
			int maxj = i+1;
			if ( maxj == ary.length ) break;
			int mini = i;
			for( int j = i+2 ; j < ary.length ; j++ ) {
				if ( ary[maxj] <= ary[j]) {
					maxj = j;
				}
			}
			for( int k = i+1 ; k < maxj ; k++ ) {
				if ( ary[k] < ary[mini]) {
					mini = k;
				}
			}
			int maxdfw = ary[maxj]- ary[mini];
			if ( maxdf < maxdfw) {
				maxdf = maxdfw ;
			}
			i = maxj;
		}
		System.out.println(maxdf);
		
	} main {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();
		int[] ary = getAryMl(breader);
		int maxdf = ary[1] - ary[0] ;
		for( int i = 0 ; i < ary.length ; i++ ) {
			int maxj = i+1;
			if ( maxj == ary.length ) break;
			int mini = i;
			for( int j = i+2 ; j < ary.length ; j++ ) {
				if ( ary[maxj] <= ary[j]) {
					maxj = j;
				}
			}
			for( int k = i+1 ; k < maxj ; k++ ) {
				if ( ary[k] < ary[mini]) {
					mini = k;
				}
			}
			int maxdfw = ary[maxj]- ary[mini];
			if ( maxdf < maxdfw) {
				maxdf = maxdfw ;
			}
			i = maxj;
		}
		System.out.println(maxdf);
		
	} BufferedReader breader = getReader(); breader getReader() getReader int[] ary = getAryMl(breader); ary getAryMl(breader) getAryMl breader int maxdf = ary[1] - ary[0] ; maxdf ary[1] - ary[0] ary[1] ary 1 ary[0] ary 0 for( int i = 0 ; i < ary.length ; i++ ) {
			int maxj = i+1;
			if ( maxj == ary.length ) break;
			int mini = i;
			for( int j = i+2 ; j < ary.length ; j++ ) {
				if ( ary[maxj] <= ary[j]) {
					maxj = j;
				}
			}
			for( int k = i+1 ; k < maxj ; k++ ) {
				if ( ary[k] < ary[mini]) {
					mini = k;
				}
			}
			int maxdfw = ary[maxj]- ary[mini];
			if ( maxdf < maxdfw) {
				maxdf = maxdfw ;
			}
			i = maxj;
		} int i = 0 ; int i = 0 ; i 0 i < ary.length i ary.length ary ary.length i++ i++ i {
			int maxj = i+1;
			if ( maxj == ary.length ) break;
			int mini = i;
			for( int j = i+2 ; j < ary.length ; j++ ) {
				if ( ary[maxj] <= ary[j]) {
					maxj = j;
				}
			}
			for( int k = i+1 ; k < maxj ; k++ ) {
				if ( ary[k] < ary[mini]) {
					mini = k;
				}
			}
			int maxdfw = ary[maxj]- ary[mini];
			if ( maxdf < maxdfw) {
				maxdf = maxdfw ;
			}
			i = maxj;
		} {
			int maxj = i+1;
			if ( maxj == ary.length ) break;
			int mini = i;
			for( int j = i+2 ; j < ary.length ; j++ ) {
				if ( ary[maxj] <= ary[j]) {
					maxj = j;
				}
			}
			for( int k = i+1 ; k < maxj ; k++ ) {
				if ( ary[k] < ary[mini]) {
					mini = k;
				}
			}
			int maxdfw = ary[maxj]- ary[mini];
			if ( maxdf < maxdfw) {
				maxdf = maxdfw ;
			}
			i = maxj;
		} int maxj = i+1; maxj i+1 i 1 if ( maxj == ary.length ) break; maxj == ary.length maxj ary.length ary ary.length break; int mini = i; mini i for( int j = i+2 ; j < ary.length ; j++ ) {
				if ( ary[maxj] <= ary[j]) {
					maxj = j;
				}
			} int j = i+2 ; int j = i+2 ; j i+2 i 2 j < ary.length j ary.length ary ary.length j++ j++ j {
				if ( ary[maxj] <= ary[j]) {
					maxj = j;
				}
			} {
				if ( ary[maxj] <= ary[j]) {
					maxj = j;
				}
			} if ( ary[maxj] <= ary[j]) {
					maxj = j;
				} ary[maxj] <= ary[j] ary[maxj] ary maxj ary[j] ary j {
					maxj = j;
				} maxj = j maxj j for( int k = i+1 ; k < maxj ; k++ ) {
				if ( ary[k] < ary[mini]) {
					mini = k;
				}
			} int k = i+1 ; int k = i+1 ; k i+1 i 1 k < maxj k maxj k++ k++ k {
				if ( ary[k] < ary[mini]) {
					mini = k;
				}
			} {
				if ( ary[k] < ary[mini]) {
					mini = k;
				}
			} if ( ary[k] < ary[mini]) {
					mini = k;
				} ary[k] < ary[mini] ary[k] ary k ary[mini] ary mini {
					mini = k;
				} mini = k mini k int maxdfw = ary[maxj]- ary[mini]; maxdfw ary[maxj]- ary[mini] ary[maxj] ary maxj ary[mini] ary mini if ( maxdf < maxdfw) {
				maxdf = maxdfw ;
			} maxdf < maxdfw maxdf maxdfw {
				maxdf = maxdfw ;
			} maxdf = maxdfw maxdf maxdfw i = maxj i maxj System.out.println(maxdf) System.out.println System.out System System.out maxdf String[] args args public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	} getReader {
		return( new BufferedReader(new InputStreamReader(System.in)));
	} return( new BufferedReader(new InputStreamReader(System.in))); ( new BufferedReader(new InputStreamReader(System.in))) public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	} getInt {
		String line = br.readLine();
		return Integer.valueOf(line);
	} String line = br.readLine(); line br.readLine() br.readLine br return Integer.valueOf(line); Integer.valueOf(line) Integer.valueOf Integer line BufferedReader br br public static int[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	} getAry {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	} String line = br.readLine(); line br.readLine() br.readLine br String[] nstr = line.split(" "); nstr line.split(" ") line.split line " " int[] n = new int[nstr.length]; n new int[nstr.length] nstr.length nstr nstr.length for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		} int i=0 ; int i=0 ; i 0 i < nstr.length i nstr.length nstr nstr.length i++ i++ i {
			n[i] = Integer.valueOf(nstr[i]);
		} {
			n[i] = Integer.valueOf(nstr[i]);
		} n[i] = Integer.valueOf(nstr[i]) n[i] n i Integer.valueOf(nstr[i]) Integer.valueOf Integer nstr[i] nstr i return n; n BufferedReader br br public static int[] getAryMl(BufferedReader br)throws Exception {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	} getAryMl {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	} int n = getInt(br); n getInt(br) getInt br int[] ary = new int[n]; ary new int[n] n for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		} int i=0 ; int i=0 ; i 0 i < n i n i++ i++ i {
			ary[i] = getInt(br);
		} {
			ary[i] = getInt(br);
		} ary[i] = getInt(br) ary[i] ary i getInt(br) getInt br return ary; ary BufferedReader br br public static void putAry(int[] ary, int num) {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	} putAry {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	} for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		} int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		} {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		} System.out.print(ary[i]) System.out.print System.out System System.out ary[i] ary i if ( i < num-1) {
				System.out.print(" ");
			} i < num-1 i num-1 num 1 {
				System.out.print(" ");
			} System.out.print(" ") System.out.print System.out System System.out " " System.out.println("") System.out.println System.out System System.out "" int[] ary ary int num num public static void putAry(int[] ary) {
		putAry(ary, ary.length ) ;
	} putAry {
		putAry(ary, ary.length ) ;
	} putAry(ary, ary.length ) putAry ary ary.length ary ary.length int[] ary ary public static boolean isPrime(int n) {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	} isPrime {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	} int r = (int)Math.sqrt((double)n)+1; r (int)Math.sqrt((double)n)+1 (int)Math.sqrt((double)n) Math.sqrt Math (double)n 1 for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		} int j = 2 ; int j = 2 ; j 2 j < r j r j += 1 j += 1 j 1 {
			if ( n%j == 0 ) {
				return false;
			}
		} {
			if ( n%j == 0 ) {
				return false;
			}
		} if ( n%j == 0 ) {
				return false;
			} n%j == 0 n%j n j 0 {
				return false;
			} return false; false return true; true int n n public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();
		int[] ary = getAryMl(breader);
		int maxdf = ary[1] - ary[0] ;
		for( int i = 0 ; i < ary.length ; i++ ) {
			int maxj = i+1;
			if ( maxj == ary.length ) break;
			int mini = i;
			for( int j = i+2 ; j < ary.length ; j++ ) {
				if ( ary[maxj] <= ary[j]) {
					maxj = j;
				}
			}
			for( int k = i+1 ; k < maxj ; k++ ) {
				if ( ary[k] < ary[mini]) {
					mini = k;
				}
			}
			int maxdfw = ary[maxj]- ary[mini];
			if ( maxdf < maxdfw) {
				maxdf = maxdfw ;
			}
			i = maxj;
		}
		System.out.println(maxdf);
		
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static int[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static int[] getAryMl(BufferedReader br)throws Exception {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	}
	public static void putAry(int[] ary, int num) {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}
	public static void putAry(int[] ary) {
		putAry(ary, ary.length ) ;
	}
	public static boolean isPrime(int n) {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	}

} public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();
		int[] ary = getAryMl(breader);
		int maxdf = ary[1] - ary[0] ;
		for( int i = 0 ; i < ary.length ; i++ ) {
			int maxj = i+1;
			if ( maxj == ary.length ) break;
			int mini = i;
			for( int j = i+2 ; j < ary.length ; j++ ) {
				if ( ary[maxj] <= ary[j]) {
					maxj = j;
				}
			}
			for( int k = i+1 ; k < maxj ; k++ ) {
				if ( ary[k] < ary[mini]) {
					mini = k;
				}
			}
			int maxdfw = ary[maxj]- ary[mini];
			if ( maxdf < maxdfw) {
				maxdf = maxdfw ;
			}
			i = maxj;
		}
		System.out.println(maxdf);
		
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static int[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static int[] getAryMl(BufferedReader br)throws Exception {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	}
	public static void putAry(int[] ary, int num) {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}
	public static void putAry(int[] ary) {
		putAry(ary, ary.length ) ;
	}
	public static boolean isPrime(int n) {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	}

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();
		int[] ary = getAryMl(breader);
		int maxdf = ary[1] - ary[0] ;
		for( int i = 0 ; i < ary.length ; i++ ) {
			int maxj = i+1;
			if ( maxj == ary.length ) break;
			int mini = i;
			for( int j = i+2 ; j < ary.length ; j++ ) {
				if ( ary[maxj] <= ary[j]) {
					maxj = j;
				}
			}
			for( int k = i+1 ; k < maxj ; k++ ) {
				if ( ary[k] < ary[mini]) {
					mini = k;
				}
			}
			int maxdfw = ary[maxj]- ary[mini];
			if ( maxdf < maxdfw) {
				maxdf = maxdfw ;
			}
			i = maxj;
		}
		System.out.println(maxdf);
		
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static int[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static int[] getAryMl(BufferedReader br)throws Exception {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	}
	public static void putAry(int[] ary, int num) {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}
	public static void putAry(int[] ary) {
		putAry(ary, ary.length ) ;
	}
	public static boolean isPrime(int n) {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	}

}