import java.util.*;

class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int size = sc.nextInt();
		int b = sc.nextInt();
		int max = b;
		int out = 0;
		int min = b;
		int sec = -1000000000;
		int thr = -1000000000;
		for(int i = 1;i <= size - 1;i++){
			int num = sc.nextInt();
			if (max <= num){
				max = num;
				if(sec < max - min){
					sec = max - min;
				}		
			}else if(min > num){
				min = num;
				if(thr < min - max){
					thr = min - max;
				}
				max = num;
			}
			
		}
		if(sec < thr){
			out = thr;
		}else{
			out = sec;
		}
		System.out.println(out);
	}
	
	
} import java.util.*; util.* java class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int size = sc.nextInt();
		int b = sc.nextInt();
		int max = b;
		int out = 0;
		int min = b;
		int sec = -1000000000;
		int thr = -1000000000;
		for(int i = 1;i <= size - 1;i++){
			int num = sc.nextInt();
			if (max <= num){
				max = num;
				if(sec < max - min){
					sec = max - min;
				}		
			}else if(min > num){
				min = num;
				if(thr < min - max){
					thr = min - max;
				}
				max = num;
			}
			
		}
		if(sec < thr){
			out = thr;
		}else{
			out = sec;
		}
		System.out.println(out);
	}
	
	
} Main public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int size = sc.nextInt();
		int b = sc.nextInt();
		int max = b;
		int out = 0;
		int min = b;
		int sec = -1000000000;
		int thr = -1000000000;
		for(int i = 1;i <= size - 1;i++){
			int num = sc.nextInt();
			if (max <= num){
				max = num;
				if(sec < max - min){
					sec = max - min;
				}		
			}else if(min > num){
				min = num;
				if(thr < min - max){
					thr = min - max;
				}
				max = num;
			}
			
		}
		if(sec < thr){
			out = thr;
		}else{
			out = sec;
		}
		System.out.println(out);
	} main {
		Scanner sc = new Scanner(System.in);
		int size = sc.nextInt();
		int b = sc.nextInt();
		int max = b;
		int out = 0;
		int min = b;
		int sec = -1000000000;
		int thr = -1000000000;
		for(int i = 1;i <= size - 1;i++){
			int num = sc.nextInt();
			if (max <= num){
				max = num;
				if(sec < max - min){
					sec = max - min;
				}		
			}else if(min > num){
				min = num;
				if(thr < min - max){
					thr = min - max;
				}
				max = num;
			}
			
		}
		if(sec < thr){
			out = thr;
		}else{
			out = sec;
		}
		System.out.println(out);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int size = sc.nextInt(); size sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int max = b; max b int out = 0; out 0 int min = b; min b int sec = -1000000000; sec -1000000000 1000000000 int thr = -1000000000; thr -1000000000 1000000000 for(int i = 1;i <= size - 1;i++){
			int num = sc.nextInt();
			if (max <= num){
				max = num;
				if(sec < max - min){
					sec = max - min;
				}		
			}else if(min > num){
				min = num;
				if(thr < min - max){
					thr = min - max;
				}
				max = num;
			}
			
		} int i = 1; int i = 1; i 1 i <= size - 1 i size - 1 size 1 i++ i++ i {
			int num = sc.nextInt();
			if (max <= num){
				max = num;
				if(sec < max - min){
					sec = max - min;
				}		
			}else if(min > num){
				min = num;
				if(thr < min - max){
					thr = min - max;
				}
				max = num;
			}
			
		} {
			int num = sc.nextInt();
			if (max <= num){
				max = num;
				if(sec < max - min){
					sec = max - min;
				}		
			}else if(min > num){
				min = num;
				if(thr < min - max){
					thr = min - max;
				}
				max = num;
			}
			
		} int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc if (max <= num){
				max = num;
				if(sec < max - min){
					sec = max - min;
				}		
			}else if(min > num){
				min = num;
				if(thr < min - max){
					thr = min - max;
				}
				max = num;
			} max <= num max num {
				max = num;
				if(sec < max - min){
					sec = max - min;
				}		
			} max = num max num if(sec < max - min){
					sec = max - min;
				} sec < max - min sec max - min max min {
					sec = max - min;
				} sec = max - min sec max - min max min if(min > num){
				min = num;
				if(thr < min - max){
					thr = min - max;
				}
				max = num;
			} min > num min num {
				min = num;
				if(thr < min - max){
					thr = min - max;
				}
				max = num;
			} min = num min num if(thr < min - max){
					thr = min - max;
				} thr < min - max thr min - max min max {
					thr = min - max;
				} thr = min - max thr min - max min max max = num max num if(sec < thr){
			out = thr;
		}else{
			out = sec;
		} sec < thr sec thr {
			out = thr;
		} out = thr out thr {
			out = sec;
		} out = sec out sec System.out.println(out) System.out.println System.out System System.out out String args[] args
import java.util.*;

class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int size = sc.nextInt();
		int b = sc.nextInt();
		int max = b;
		int out = 0;
		int min = b;
		int sec = -1000000000;
		int thr = -1000000000;
		for(int i = 1;i <= size - 1;i++){
			int num = sc.nextInt();
			if (max <= num){
				max = num;
				if(sec < max - min){
					sec = max - min;
				}		
			}else if(min > num){
				min = num;
				if(thr < min - max){
					thr = min - max;
				}
				max = num;
			}
			
		}
		if(sec < thr){
			out = thr;
		}else{
			out = sec;
		}
		System.out.println(out);
	}
	
	
}